$conditions = array("OR"=>
array("Message.to_to"=>$daddy["User"]["id"],
"Message.from_from"=>$this->Auth->user("id")),
array("Message.to_to"=>$this->Auth->user("id"),
"Message.from_from"=>$daddy["User"]["id"])
);
答案 0 :(得分:0)
要获得预期结果(A == 1 AND B == 2)或(A == 2和B == 1),请尝试嵌套'和'您的代码中目前缺少的条件。
您还需要指定conditions参数。
尝试以下方法:
$conditions = array(
'conditions' => array(
"or"=> array(
"and" => array(
"Message.to_to"=>$daddy["User"]["id"],
"Message.from_from"=>$this->Auth->user("id"),
),
"and" => array(
"Message.to_to"=>$this->Auth->user("id"),
"Message.from_from"=>$daddy["User"]["id"],
),
),
),
);
参考:http://book.cakephp.org/2.0/en/models/retrieving-your-data.html