php - Does the Yii CActiveRecord class have a first() method? -
i need first record yii cactiverecord derived class. in rails able this:
post = post.first
i thought same thing yii this:
$post = post::model()->first();
but method doesn't exist. have find status first record?
i don't see first() in docs cactiverecord assume reply no, doesn't have first method. how 1 go querying first record?
this works sure ugly hack. certainly there's improve way.
$first = post::model()->findall(array('order'=>id, 'limit'=>1));
cactiverecord::find()
returns 1 model.
$first=post::model()->find();
php yii
No comments:
Post a Comment