public function search_between() {
$min = $this->request->query['min'];
$max = $this->request->query['max'];
$conditions = array('Ad.price BETWEEN ? AND ?' => array($min,$max));
$ads = $this->Anuncio->find('all',array('conditions' => $conditions));
$this->set('ads',$ads);
}
警告:strlen()期望参数1为字符串,给定数组。
**Thank's for your help I'm new to asking questions here.**
答案 0 :(得分:0)
试试这个:
public function search_between() {
$min = $this->request->query['min'];
$max = $this->request->query['max'];
$conditions = array('Anuncio.price >=' => $min,'Anuncio.price <=' $max));
$ads = $this->Anuncio->find('all',array('conditions' => $conditions));
$this->set('ads',$ads);
答案 1 :(得分:0)
你可以使用Cakephp mysql查询它将像cakephp查询一样工作
if(!empty($min) && !empty($max)){
$ads = $this->Anuncio->query('SELECT * from Anuncio WHERE Anuncio.price BETWEEN "'.$min.'" AND "'.$max.'"');
}
else{
$ads = $this->Anuncio->query('SELECT * from Anuncio');
}