Поисковая система с доктриной в Symfony - PullRequest
0 голосов
/ 17 августа 2011
  public function executeSearch(sfWebRequest $request)
  {      
    $q = Doctrine_Core::getTable('News')
              ->createQuery('a')
              ->where("a.title LIKE ?", array($request->getParameter('text')))

    if ($request->getParameter('sub')){
               ->andWhere('a.subtile = 2');
    }
    $test = $q->execute();
  }

Почему это не работает?У меня есть ошибка разбора.Как это сделать в Symfony 1.4?

1 Ответ

2 голосов
/ 18 августа 2011
public function executeSearch(sfWebRequest $request)
{      
  $q = Doctrine_Core::getTable('News')
          ->createQuery('a')
          ->where("a.title LIKE ?", array($request->getParameter('text')));

  if ($request->getParameter('sub')){
           $test->andWhere('a.subtile = 2');
  }
  $test = $q->execute();
}

будет правильный синтаксис

может быть, вы также хотите добавить %% к вашему запросу ->where("a.title LIKE %?%"

...