标签:
http://ioutsider.me/yii-shu-ju-ku-cao-zuo-zhi-dao.html
新增数据:
Yii::app()->db->createCommand()->insert(‘es_users‘, array(‘name‘=>‘Outsider‘));
|
删除数据:
Yii::app()->db->createCommand()->delete(‘es_users‘, ‘id=:id‘, array(‘:id‘=>2));
|
更新数据:
$res = Yii::app()->db->createCommand()->update(‘es_users‘, array(‘name‘=>‘局外人‘), ‘id=:id‘,array(‘:id‘=>2));
|
查询数据:
查询一条记录
$row = Yii::app()->db->createCommand()->from(‘es_user‘)->where(‘id=:id‘,array(‘:id‘=>2))->queryRow();
|
查询符合条件的多条记录:
Yii::app()->db->createCommand()->select(‘id,name,email‘)->from(‘es_user‘)->where(‘id>:id and id<5‘,array(‘:id‘=>1))->queryAll();
标签:
原文地址:http://www.cnblogs.com/gzmg/p/4654154.html