root query
This commit is contained in:
parent
b58b92bc30
commit
b1d6490d24
|
@ -42,9 +42,8 @@ class IndexController extends AbstractController
|
|||
#[Route('/notification/dm', name: 'notification_dm')]
|
||||
public function notificationDm(Request $request, MerServiceRepository $repo): Response
|
||||
{
|
||||
foreach ($repo->findByOfferId($request->query->get('offer_id')) as $sub) {
|
||||
dump($sub);
|
||||
}
|
||||
dump('MerServiceRepository->findByOfferId');
|
||||
dump($repo->findByOfferId($request->query->get('offer_id')));
|
||||
|
||||
return $this->render('index/notificationDm.html.twig');
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace App\Repository;
|
|||
|
||||
use App\Entity\MerService;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
|
@ -65,11 +67,29 @@ class MerServiceRepository extends ServiceEntityRepository
|
|||
|
||||
public function findByOfferId(int $offerId)
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->andWhere('s.offer_id = :offer_id')
|
||||
->setParameter('offer_id', $offerId)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.offer_id = :offer_id')
|
||||
// ->setParameter('offer_id', $offerId)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
|
||||
$rsm = new ResultSetMapping();
|
||||
$rsm->addEntityResult($this->getClassName(), 's');
|
||||
$rsm->addFieldResult('s', 'id', 'id');
|
||||
$rsm->addMetaResult('s', 'discr', 'discr');
|
||||
$rsm->setDiscriminatorColumn('s', 'discr');
|
||||
|
||||
$query = $this->getEntityManager()
|
||||
->createNativeQuery('SELECT * FROM mer_service m WHERE offer_id = :offer_id', $rsm);
|
||||
$query->setParameter('offer_id', $offerId);
|
||||
|
||||
$res = $query->getResult();
|
||||
|
||||
foreach ($res as $k => $obj) {
|
||||
$this->getEntityManager()->refresh($obj);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue