Dynamic Relational Query with CDbCriteria - Is possible?

Hello again, today I have a question related to AR and Dynamic Relational Query Options (Based on this http://www.yiiframew…de/database.arr)

I know that I can pass some array when I use lazy loadong aproach:

ej:



<?php


$user=User::model()->findByPk(1);


$posts=$user->posts(array('condition'=>'status=1'));


This works pretty well, but I want to do something like that:



<?php


$user=User:model()->findByPk(1);





$criteria = new CDbCriteria;


$criteria->condition = 'status=1';





$posts=$user->posts($criteria);


But this does'n work (at least for me)…

It's possible to do this?

I just checked in the code to support this. Thanks.

sorry qiang, may be I have somethig wrong, but when I update (the svn, 1.0) and test again throws me this error:



Fatal error: Cannot use object of type CDbCriteria as array in C:wampwwwyii-1.0frameworkdbarCActiveRecord.php on line 1993


My bad. Please use $criteria->toArray() instead. Allowing using $criteria directly is more troublesome.

Yes! I just figured out when update again! thanks!