I want to fetch firstname from customer table. In my data base there is 2 table first is Customerlifecycle there is 1 column name is customer_id and secound table is customer there is 2 column 1st is id and 2nd is firstname.
$criteria = new CDbCriteria;
$criteria->join = 'LEFT OUTER JOIN customer AS C ON C.id = t.customer_id AND C.store_id=' . Yii::app()->session['store_id'];
$criteria->select = 'C.firstname as firstname';
$criteria->group = 'C.firstname';
$criteria->condition = 'store_id=\'' . Yii::app()->session['store_id'] . '\'';
$list = CustomerLifecycle::model()->findAll($criteria);
I can not fetch firstname please help me
please try below code
$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);