1

这真让我抓狂。这不会引发任何错误,但也不会执行连接。我希望这是我花了太长时间研究它的地方,而答案对其他人来说是显而易见的......

        $lines = $this->RevenueLine->find('all', array(
                'conditions' => array(
                    'RevenueLine.is_triggered' => 1,
                    'RevenueLine.date_triggered >=' => $sqldate1,
                    'RevenueLine.date_triggered <=' => $sqldate2,
                ),
                'joins' => array(
                    array(
                        'table' => 'projects',
                        'alias' => 'Project',
                        'type' => 'INNER',
                        'conditions' => array(
                            'RevenueLine.project_id = Project.id'
                        )
                    ),
                    array(
                        'table' => 'clients',
                        'alias' => 'Client',
                        'type' => 'INNER',
                        'conditions' => array(
                            'Project.client_id = Client.id'
                        )
                    ),
                    array(
                        'table' => 'classifications',
                        'alias' => 'Classification',
                        'type' => 'INNER',
                        'conditions' => array(
                            'Project.classification_id = Classification.id'
                        )
                    )                       
                ),
                'order' => array(
                    'Client.client_number ASC', 
                    'Project.pn_counter ASC'
                )
            )
        );
4

1 回答 1

2

您需要从连接表中选择字段:

'fields' => array(
     'JoinTable1.*',
     'JoinTable2.*',
     'JoinTable3.*',
     'JoinTable4.*'
)

作为您的发现的参数。

于 2013-08-01T14:44:56.840 回答