Help Me With Findbyattributes Within A Join Table

Please help me with this question. I want to do a query to get dataset and related authors like this,

$models = Dataset::model()->with(‘authors’)->findByAttributes(array(‘name’=>$_GET[‘name’]));

name is in the authors table but not dataset table. But it does not work.

What did I do wrong or how could I fix this problem?


Try :

$models = Dataset::model()->with('authors')->findAllByAttributes(array(''=>$_GET['name'])); 

  1. Did you set relationship between authors and dataset? If not this should be the first step when you create model dataset

  2. findByAttributes and findAllByAttributes will return different result. If you want to return CActiveRcords[], use findAllByAttributes like Ronald did.

See more detail in