I am new in yii
framework. I'm trying to get all records by conditition from a table using model but every time I failed. I solved it by simple mysqli1
query. But i want to get it yii findAll();
. Below my i tried
$criteria = new CDbCriteria;
$criteria->select('*');
$criteria->condition('u_id = $id');
$info = Info::model()->findAll($criteria);
Thank all!
select('*')
should be select = "*"
and condition('u_id = $id')
should be "u_id = $id"
. Try like below
$criteria = new CDbCriteria;
$criteria->select = '*';
$criteria->condition = "u_id = $id";
$info = Info::model()->findAll($criteria);
This is my way to do it:
$id =10;
$info = Info::model()->findAll(array("u_id"=> $id ));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.