2015-01-04 67 views
-1

我該如何在cakephp sql查詢方式中編寫這些類型的語句。Cakephp Sql查詢

SELECT * 
FROM `officers` 
WHERE ((slot1_min<=00 AND slot1_max>=0) OR (slot2_min<=850 AND slot2_max>=850)) 

回答

2

TRY:

$options = array(
    'conditions' => array(
     'OR' => array(
      array(
       'AND' => array(
        array('slot1_min <=' => 0), 
        array('slot1_max >=' => 0), 
      ) 
     ), 
      array(
       'AND' => array(
        array('slot2_min <=' => 850), 
        array('slot2_max >=' => 850), 
      ) 
     ), 
     ) 
    ) 
); 
$officers = $this->Officer->find('all',$options);