Created
September 8, 2015 01:52
-
-
Save miguelplazasr/c2303c55d97ede9fc05d to your computer and use it in GitHub Desktop.
City Query by State
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
<?php | |
namespace AppBundle\Entity; | |
use Doctrine\ORM\EntityRepository; | |
/** | |
* CityRepository | |
* | |
* This class was generated by the Doctrine ORM. Add your own custom | |
* repository methods below. | |
*/ | |
class CityRepository extends EntityRepository | |
{ | |
public function findByStateId($state_id) | |
{ | |
$query = $this->getEntityManager()->createQuery(" | |
SELECT c | |
FROM AppBundle:City c | |
LEFT JOIN c.state s | |
WHERE s.id = :state_id | |
")->setParameter('state_id', $state_id); | |
return $query->getArrayResult(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment