gpt4 book ai didi

php - 我想从客户表中获取名字

转载 作者:行者123 更新时间:2023-11-30 22:32:39 25 4
gpt4 key购买 nike

我想从客户表中获取名字。在我的数据库中有 2 个表,第一个是 Customerlifecycle,有 1 个列名是 customer_id,第二个表是 customer,有 2 个列,第一个是 id,第二个是名字。

 $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);

我无法获取名字请帮助我

最佳答案

请尝试下面的代码

        $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);

关于php - 我想从客户表中获取名字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33449124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com