Problem : dataprovider and related tables condition

I have 3 related tables (with their models)

Table1 -> model1

id, name

Table2 -> model2 (relation name = table1 on table1_fk foreign key field)

id, family, table1_fk

Table3 -> model3 (relation name = table2 on table2_fk foreign key field)

id, number, table2_fk

Now in my view.php from my table3 CRUD I have this dataprovider

[color="#222222"][font="Arial, sans-serif"][size="4"]

$dataProvider=new CActiveDataProvider('model3', array('criteria'=>array('condition'=> <img src='' class='bbc_emoticon' alt='???' />, ),));


? ? ? -> I want to have records in model3 where their related name in model1 are "Ali" what is the proper criteria for this reason?

should I use "with" ? what is the clue?


Something like:

$dataProvider=new CActiveDataProvider(



 'condition'=> 'name = :name', 




You may need to change the with accordingly to your relations, and also you may need to disambiguate the field ‘name’ with the alias, wich should be t3

it doesn’t work. how can I use table alias name?

with=>array(‘table2’) it works but the second level means with=>array(‘table2’=>array(‘table1’)) it raises an error and it cant access table1 through table3