Created
June 28, 2012 14:34
-
-
Save irwinv/3011703 to your computer and use it in GitHub Desktop.
Free Query with getConnection in EntityRepository
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 Patrick\ElevageBundle\Repository; | |
use Doctrine\ORM\EntityRepository; | |
class ChienRepository extends EntityRepository | |
{ | |
public function getChiensParRace($chiot, $race){ | |
$conn = $this->_em->getConnection('database_connection'); | |
$sql = " | |
SELECT *, c.id AS idc FROM Chiens c | |
LEFT JOIN Images i ON c.id = i.chien_id | |
WHERE c.chiot = :chiot | |
&& c.race = :race | |
GROUP BY i.chien_id | |
ORDER BY c.nom ASC | |
"; | |
return $conn->fetchAll($sql, $params = array('chiot' => $chiot, 'race' => $race)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment