这里我有一个预订表,其中包括医生和患者...我想要的是每位医生的约会次数。但是,在我的桌子上,我有两位医生,有几份约会。因此,我希望我的学说要求能返回我的两名医生名单及其任命总数,但它将返回我所有任命的实例。
我在phpMyAdmin中的sql请求这是我想要的结果:
我的控制器
public function bookingbydocAction(Request $request){
$user = $this->getUser();
if ($user === null) {
throw new NotFoundHttpException('Utilisateur Inexistant');
} else {
$em = $this->getDoctrine()->getManager();
$medecin = $em->getRepository('DoctixMedecinBundle:Medecin')->findAll();
$bookings = $em->getRepository('DoctixFrontBundle:Booking')->findBy(array('medecin' => $medecin));
$nbbookhonored = $em->createQuery('SELECT COUNT(b.id) AS nbr_booking_honored FROM
DoctixFrontBundle:Booking b WHERE b.statut like :approved GROUP BY b.medecin' )-
>setParameter('approved', 'approved')->getResult();
$nbbookbydoc = $em->createQuery('SELECT COUNT(b.id) AS nbr_booking_by_doc FROM
DoctixFrontBundle:Booking b GROUP BY b.medecin' )->getResult();
$nbbookhonored = $nbbookhonored[0]['nbr_booking_honored'];
$nbbookbydoc = $nbbookbydoc[0]['nbr_booking_by_doc'];
return $this->render('DoctixAdminBundle:User:booking_medecin.html.twig', array(
'bookings' => $bookings,
'nbbookhonored' => $nbbookhonored,
'nbbookbydoc' => $nbbookbydoc
));
}
}
我的观点树枝
<div class="table-responsive-sm">
<table class="table table-sm table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>#</th>
<th>NOM COMPLET</th>
<th>EMAIL</th>
<th>TÉLÉPHONE</th>
<th>NOMBRE RENDEZ-VOUS</th>
<th>HONORES</th>
</tr>
</thead>
<tfoot>
<tr>
<th>#</th>
<th>NOM COMPLET</th>
<th>EMAIL</th>
<th>TÉLÉPHONE</th>
<th>NOMBRE RENDEZ-VOUS</th>
<th>HONORES</th>
</tr>
</tfoot>
<tbody>
{% for booking in bookings %}
<tr>
<td>{{ loop.index }}</td>
<td>{{ booking.medecin.user.prenom|capitalize }} {{ booking.medecin.user.nom|upper }}</td>
<td>
{{ booking.medecin.user.username }}
</td>
<td>{{ booking.medecin.user.numTel }}</td>
<td>{{ nbbookbydoc }}</td>
<td>
{{ nbbookhonored }}
</td>
</tr>
{% endfor %}
<div class="navigation"> </div>
</tbody>
</table>
</div>
问题是,这使我看到了有两位任命医生的所有情况,或者我希望他为我带来每位医生的一个实例以及他们各自任命的总数。] >
谢谢
这里我有一个预订表,其中包括医生和患者。我想要的是每个医生的约会数量。但是在我的桌子上,我有两位医生,有几个约会。...
根据Doctrine的最佳实践,您应该使用存储库: