开发者

Error with join and CakePHP

开发者 https://www.devze.com 2023-02-22 01:18 出处:网络
What am I doing wrong here? $sub_data = $this->Subscriber->find(\'all\', array( \'joins\' => array(

What am I doing wrong here?

        $sub_data = $this->Subscriber->find('all', array(
            'joins' => array(
                'table' => 'subtypes',
                'alias' => 'Subtype',
                'type' => 'LEFT',
                'conditions' => array(
                    'Subtype.id = Subscriber.plan',
                )
            ),
            'conditions' => array(
                'Subs开发者_运维百科criber.plan' => $plan['Subtype']['id'],
                'Subscriber.authcode !=' => '',
                'Subscriber.subended' => '0000-00-00 00:00:00',
                'Subtype.authorize_trial_only' => '1',
            )
        ));

Somehow the final statement is not being generated correctly. That's that part where I get a SQL error:

... 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 ...


Should it be

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

Or am I just crazy?

EDIT:

Do you perhaps need to add another level of array() in there? i.e.

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

精彩评论

暂无评论...
验证码 换一张
取 消