【发布时间】:2012-01-04 23:22:01
【问题描述】:
我正在处理一些非常糟糕的继承代码,并且有一个查询从表中提取事件。事件模型有$hasOne = array('blocked'); - 我的目标是只返回在被阻止的表中没有条目的所有事件。尽管 $hasOne 设置蛋糕仍然单独查询被阻止的事件表,所以我永远不能使用这些字段作为条件。
查询本身已经在 'contains' => ... 内,因此使用 'joins' => ... 手动强制连接不起作用。
更新:这是现在存在的查找查询:
$params = array(
'conditions' => array(
'Restaurant.id' => $id,
'Restaurant.inactive' => 0, 'Restaurant.deleted' => 0,
'Restaurant.bkwindow <=' => (strtotime($criteria['Restaurant']['date']) - strtotime("today"))/86400
),
'fields' => array(),
'contain' => array(
'Experience' => array(
'Experience_blocking'
)
)
);
我需要 Experience 表仅返回 Experience_blocking 表中没有条目的结果。经验是通过 Experience_blocking 的 $hasOne 设置的,但它永远不会起作用,它总是将其作为可包含项进行查询。
【问题讨论】:
标签: php cakephp cakephp-1.3