如何使用 YIi 查询生成器构建此查询
SELECT First_Name,User_ID,
FROM `Users`
WHERE First_name LIKE $_GET['name']
正如 Örs 所说,一切都在Yii 指南中!
$user = Yii::app()->db->createCommand()
->select('First_Name, User_ID')
->from('Users')
->where('First_name like :name', array(':name'=>$_GET['name']))
->queryRow();
$cr = new CDbCriteria();
$cr->condition = "First_name LIKE '%:name%'";
$cr->params = array(':name'=>$_GET['name']);
$users = Users::model()->findAll($cr);
其他方式