cyberpol
(Cyberpol 777)
1
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?
qiang
(Qiang Xue)
2
I just checked in the code to support this. Thanks.
cyberpol
(Cyberpol 777)
3
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
qiang
(Qiang Xue)
4
My bad. Please use $criteria->toArray() instead. Allowing using $criteria directly is more troublesome.
cyberpol
(Cyberpol 777)
5
Yes! I just figured out when update again! thanks!