class PostRepository extends EntityRepository
{
private $em;
public function __construct(EntityManagerInterface $em, Mapping\ClassMetadata $class)
{
parent::__construct($em, $class);
$this->em = $em;
}
/**
* @param null $sql
* @param array $params
* @return array
* @throws \Exception
*/
public function findAllPostUserCommentEtcWhatEverYouWant($sql = null, $params = [])
{
try {
return $this->em->getConnection()->executeQuery($sql, $params)->fetchAll();
} catch (DBALException $e) {
}
throw new \Exception('');
}
/**
* @return array
*/
public function findThis()
{
try {
return $this->findAllPostUserCommentEtcWhatEverYouWant('select . ..');
} catch (\Exception $e) {
}
}
/**
* @return array
*/
public function findThat()
{
try {
return $this->findAllPostUserCommentEtcWhatEverYouWant('select . ..');
} catch (\Exception $e) {
}
}
/**
* @Route("/pdo", name="pdo")
*/
public function pdo(EntityManagerInterface $em)
{
$result = $em->getRepository(Post::class)->findThat();
$result = $em->getRepository(Post::class)->findThis();