gpt4 book ai didi

mysql - join 和 CakePHP 出错

转载 作者:行者123 更新时间:2023-11-29 14:51:56 25 4
gpt4 key购买 nike

我在这里做错了什么?

        $sub_data = $this->Subscriber->find('all', array(
'joins' => array(
'table' => 'subtypes',
'alias' => 'Subtype',
'type' => 'LEFT',
'conditions' => array(
'Subtype.id = Subscriber.plan',
)
),
'conditions' => array(
'Subscriber.plan' => $plan['Subtype']['id'],
'Subscriber.authcode !=' => '',
'Subscriber.subended' => '0000-00-00 00:00:00',
'Subtype.authorize_trial_only' => '1',
)
));

不知何故,最终语句未正确生成。这就是我收到 SQL 错误的部分:

... FROM subscribers AS Subscriber subtypes Subtype LEFT Array WHERE Subscriber.plan = '10' AND Subscriber.authcode != '' AND Subscriber.subended = '0000-00-00 00:00:00' AND Subtype.authorize_trial_only = '1' AND ...

最佳答案

应该是

 'conditions' => array(
'Subtype.id' => 'Subscriber.plan',
)

或者我只是疯了?

编辑:

您是否需要在其中添加另一个级别的 array() ?即

'joins' => array( array ( 'table' => ...

关于mysql - join 和 CakePHP 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5556554/

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