views:

24

answers:

1

I have a two table in relation with has_many assocation on theirselves.

How can i call has_many table with where condition?

When i call like "$news -> findNewsComment();" i get Comments. but i want specific comments, like just approved comments.

is it possible something like $news -> findNewsComment(array('state_id = ?' => '10'));

+1  A: 

I found the solution,

i should pass a Zend_Db_Table_Select object to the relation for example:

/* $newsTable must be instance of Zend_Db_Table_Abstract */
$select = new Zend_Db_Table_Select( $newsTable );
$select -> where('state_id = 10');
$news -> findNewsComment( $select );

I always dreamt like Ruby on Rails way (shorter), i think it is not possible.

davit