我想从customer表中获取firstname。 在我的数据库中有2个表首先是Customerlifecycle有1列名称是customer_id而secound表是客户有2列1是id而2nd是firstname。
IndexSearcher
我无法取名字请帮帮我
答案 0 :(得分:0)
请尝试以下代码
$criteria = new CDbCriteria;
$criteria->select = 'C.firstname as customer_id';
$criteria->condition = 't.store_id= '. Yii::app()->session['store_id'];
$criteria->join = 'LEFT OUTER JOIN customer AS C ON C.id = t.customer_id';
$criteria->group = 'C.firstname';
$list = CustomerLifecycle::model()->findAll($criteria);