I am having problem doing searches with a has_many relationship.
I have a model called "Discussion." Each Discussion has many Comments. I am trying to create a search function so that a user can search any discussion in which a given string exists in ANY of the comments.
Something like below would be really nice:
public function search($division_id = null)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->with = array('comments');
$criteria->compare('comment.text',$value,true);
...
It is pretty easy to do with a relationship where one model HAS ONE or BELONGS to another model but I am lost when it comes to HAS MANY.
Does anyone know how to do something like this? I have tried googling around and checking out this forum, but I haven’t found anything yet. Does such a feature exist?