【发布时间】:2025-12-26 16:00:12
【问题描述】:
我需要使用 CakePHP 的 find 方法进行如下查询:
SELECT * FROM fydee.clients_groups join clients on clients_groups.client_id = clients.id where clients.deleted = 0 and group_id = 7;
Client_groups.client_id 字段与clients.id 字段相同,所以这就是加入的内容。我如何在 cakephp 中创建它?
我试过了:
$clients = $this->Groups->find('all', array(
'joins' => array(
array(
'table' => 'Clients',
'alias' => 'ClientsJoin',
'type' => 'INNER',
'conditions' => array(
'ClientsJoin.id = client.id'
)
)
),
'conditions' => array(
'Group.id' => $_POST['group_id'],
'Client.deleted' => 0
)
));
【问题讨论】: