gpt4 book ai didi

cakephp - Cakephp 中的连接和计数字段

转载 作者:行者123 更新时间:2023-12-02 20:32:42 26 4
gpt4 key购买 nike

我试图在我的字段中查找计数并连接该计数,但它给出错误消息,因为找不到 make_count 并且我在上面创建了相同的字段。

$this->Car->virtualFields['make_count'] = 'COUNT(Car.car_make)';
$this->Car->virtualFields['make_concat']='CONCAT(Car.car_make,Car.make_count)';

$models = array_unique($this->Car->find('list',array(
'fields' => array('Car.car_make', 'Car.make_concat'),
'conditions'=>array('Car.ad_status'=>'saved'),
'order'=>array('Car.car_make'=>'Asc'),
'contain'=>false,
'group'=>array('Car.car_make')
)
));

最佳答案

Try:
$this->Car->virtualFields['make_concat']='CONCAT(Car.car_make,COUNT(Car.car_make))';

$models = array_unique($this->Car->find('list',array(
'fields' => array('Car.car_make', 'Car.make_concat'),
'conditions'=>array('Car.ad_status'=>'saved'),
'order'=>array('Car.car_make'=>'Asc'),
'contain'=>false,
'group'=>array('Car.car_make')
)
));

关于cakephp - Cakephp 中的连接和计数字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31675814/

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