symfony - Create repository action from form selected items in Symfony2? -
edit found how data
$filter_form->handlerequest($request); if ($filter_form->isvalid()) { $users = $filter_form->get('users')->getviewdata(); $tags = $filter_form->get('tags')->getdata(); $links = $em->getrepository('lancrmbundle:link')->findfiltered($users, $tags); } else { $links = $em->getrepository('lancrmbundle:link')->findby( array(), array('id' => 'desc') ); }
now have create findfiltered method in repository.
but don't know how make working.
public function findfiltered($users, $tags) { $querybuilder = $this->createquerybuilder('l'); $querybuilder->orderby('l.id', 'desc'); if($users) { ??? } if($tags) { ??? } return $querybuilder->getquery()->getresult(); }
i hope understandable, if not not hesitate ask me more information.
thank in advance.
you didn't specify associations types should like:
return $this->_em ->createquery( 'select l lancrmbundle:link '. 'where l.user in (:users) , l.tag in (:tags) '. 'order l.id desc') ->setparameter('users', $users) ->setparameter('tags', $tags) ->getresult();
Comments
Post a Comment