【问题标题】:hasOne is null condition for cakephp find()hasOne 是 cakephp find() 的空条件
【发布时间】: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


    【解决方案1】:

    由于您没有显示太多代码,因此我将尝试猜测您的问题是什么,并详细说明。你不能使用 Containable 行为做你想做的事。

    更详细的答案见this post

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      • 2023-04-08
      • 2010-12-17
      相关资源
      最近更新 更多