Created
September 30, 2013 23:40
-
-
Save helderjs/6771914 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @Route("/state/searchbyuser", name="state_search_by_user" | |
* @Method("GET") | |
*/ | |
public function searchByUser() | |
{ | |
$request = $this->getRequest(); | |
$user = $this->getUser(); | |
$em = $this->getDoctrine()->getManager(); | |
$query = $em->execute(' | |
SELECT | |
partial s.{id, name}, g | |
FROM Ciwwic\AppBundle\Entity\State s | |
JOIN Ciwwic\AppBundle\Entity\GroupRegion gr WITH gr.region = s.id | |
JOIN gr.group g | |
WHERE gr.type = :region_type | |
AND g.user = :user | |
AND s.name LIKE :q | |
') | |
->setParameters( | |
array( | |
'q' => $request->query->get('q') . '%', | |
'region_type' => 2, | |
'user_id' => $user, | |
) | |
) | |
->setMaxResults(5); | |
return new JsonResponse($query->getArrayResult()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment