$tmp_sales = $this->tmp_sale->find('all', array(
'conditions' => array(
array(
'no' => $no,
'barcode' => $barcode,'employee' => $emp, 'store' => $store_name
)
)
));
这是我目前的查询。
select * from tmp_sale where no = '$no' and
'employee' ='$emp' and store = '$store_name' and ( barcode='$barcode' or name='$barcode')
我想像上面那样做出改变。如何在cakephp
中编写这样的查询答案 0 :(得分:1)
'conditions' => array(
'no' => $no,
'employee' => $emp,
'store '=> $store_name,
'OR' => array(
array('barcode' => $barcode),
array('name' => $barcode)
)
)
答案 1 :(得分:-2)
Cakephp模型名称应为单数,
tmp_sale
模型名称应替换为TmpSale
名称。 cakephp的查询如下所示。 你应该试试这个
$tmp_sales = $this->TmpSale->find('all', array(
'conditions' => array( 'no' => $no,
'employee' => $emp,
'store '=>$store_name,
'or'=>array('barcode'=>$barcode,
'name'=>$barcode)
)
));
由于