cakephp - Cake php multiply Find Conditions OR /AND -
hey guys have been struggling .i trying select table using cakephp find e.g want select table (a == 1 , b == 2) or (a == 2 , b == 1) on query here code far
$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"]) );
to expected result (a == 1 , b == 2) or (a == 2 , b == 1), try nesting 'and' conditions missing code.
you need specify conditions parameter.
try following:
$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"], ), ), ), );
reference: http://book.cakephp.org/2.0/en/models/retrieving-your-data.html
Comments
Post a Comment