как написать CakePHP и и или или запрос

 $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

Решение

'conditions' => array(
'no' => $no,
'employee' => $emp,
'store '=> $store_name,
'OR' => array(
array('barcode' => $barcode),
array('name' => $barcode)
)
)
1

Другие решения

Название модели Cakephp должно быть Singular,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)

)
));

Спасибо

-2

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector