我想从customer表中获取firstname

时间:2015-10-31 07:21:45

标签: php mysql yii

我想从customer表中获取firstname。 在我的数据库中有2个表首先是Customerlifecycle有1列名称是customer_id而secound表是客户有2列1是id而2nd是firstname。

IndexSearcher

我无法取名字请帮帮我

1 个答案:

答案 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);