2

你知道我如何在 cakephp 中使用 helper find 进行这个查询吗?

$req = "SELECT * FROM brand 
        WHERE nom LIKE '$nom%'  AND 
              genre LIKE '$genre%' AND     
              mouvement LIKE '$mouvement%' AND 
              forme LIKE '$forme%' AND 
              prix >= '$mini' AND 
               prix <= '$maxi' 
         ORDER BY prix ASC";

我做了这样的事情,但它不起作用

   $results=$this->Model->find('all',array('conditions'=>array
  ('AND'=>array('name   LIKE'=>$nom,'genre LIKE'=>$genre,
  'mouvement LIKE'=>$mouvement,.....))));

提前感谢您的回复;-)

4

1 回答 1

1

尝试这个

$this->Brand->find('all',array
(
    'conditions' => array
    (
        'Brand.nom LIKE' => "{$nom}%",
        'Brand.genre LIKE' => "{$genre}%",
        'Brand.mouvement LIKE' => "{$mouvement}%",
        'Brand.forme LIKE' => "{$forme}%",
        'Brand.prix >=' => $mini,
        'Brand.prix <=' => $maxi
    ),
    'order' => array('Brand.prix' => 'ASC')
));
于 2013-01-24T08:30:35.773 回答