【发布时间】:2014-10-14 08:58:43
【问题描述】:
我正在尝试获取不包括已经在另一个表中的行:
| Content | ContentSelected
| –––––––– | ––––––––––––––––––––––––-
| id | content_id | operation_id
| 1 | 1 | 9999
| 2 | 3 | 1000
| 3
=> 2,3
这是我尝试运行此查询的方式:
Content::find('all', array(
'joins' => array(new Query(array(
'source' => 'ContentSelected',
'constraints' => array('ContentSelected.operation_id' => 9999),
'conditions' => array(
'Content.id' => array('<>' => 'ContentSelected.content_id')
));
这里是适配器运行的 SQL 查询:
SELECT * FROM "Content" AS "Content"
JOIN "ContentSelected" ON "ContentSelected"."operation_id" = 1
WHERE ("Content"."id" <> 0);
是否有其他方法可以执行不包括结果的查询,或者强制适配器在 where 子句中写入 ContentSelected.content_id 而不是 0?
谢谢
【问题讨论】:
标签: lithium