Commit b4ad93d7 authored by Mat's avatar Mat

repository, la requête qui récupère l'historique entre 2 users

parent d4244e4f
......@@ -10,4 +10,27 @@ namespace SocketBundle\Repository;
*/
class MessageRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @param $username1
* @param $username2
* @return array
*/
public function getHistory($username1, $username2)
{
$qb = $this->createQueryBuilder('m')
->join('m.author', 'a')
->join('m.receiver', 'r')
->where('(a.username = :username1 AND r.username = :username2)')
->orWhere('(a.username = :username2 AND r.username = :username1)')
->orderBy('m.date', 'ASC')
->setParameters(array(
':username1' => $username1,
':username2' => $username2
))
;
return $qb->getQuery()->getResult();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment