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