Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/08/2018, 11:27
nelson12345
 
Fecha de Ingreso: enero-2010
Ubicación: Colombia
Mensajes: 238
Antigüedad: 14 años, 2 meses
Puntos: 2
Respuesta: Imprimir resultado de conteo de registros consulta dql

Lo hice de esta forma pero me sale este error:

Invalid parameter number: number of bound variables does not match number of tokens

Código PHP:
Ver original
  1. [HIGHLIGHT="HTML"]public function perrosrazaAction(Request $request)    
  2.     {
  3.  
  4.         $raza = $request->query->get('raza');
  5. $repository = $this->getDoctrine()->getRepository('PPPCanBundle:Mascota');
  6.  
  7.         $razas = $this->getDoctrine()
  8.             ->getRepository('PPPCanBundle:Raza')
  9.             ->findAll();
  10.  
  11.         $qBase = $repository->createQueryBuilder('n')            
  12.             ->select('count(n.id)')
  13.             ->where('n.generom = :generom')
  14.             ->innerJoin('n.raza', 'r')
  15.             ->setParameter('raza', $raza);
  16.  
  17.         $qHembra = clone $qBase;
  18.         $qMacho = clone $qBase;
  19.  
  20.         $cHembra = $qHembra
  21.             ->setParameter('generom', 'HEMBRA')
  22.             ->getQuery()
  23.             ->getSingleScalarResult();
  24.  
  25.         $cMacho = $qMacho
  26.             ->setParameter('generom', 'MACHO')
  27.             ->getQuery()
  28.             ->getSingleScalarResult();
  29.  
  30.  
  31.         $data = [
  32.             'config' => [
  33.                 "raza" => $raza
  34.             ],
  35.             "result" => [
  36.                 "razas" => [],
  37.                 "generos" => [
  38.                     [
  39.                         'cantidad' => $cHembra,
  40.                         'nombre' => 'Hembra'
  41.                     ],
  42.                     [
  43.                         'cantidad' => $cMacho,
  44.                         'nombre' => 'Macho'
  45.                     ]
  46.                 ]
  47.             ]
  48.         ];
  49.  
  50. return $data;
  51.  
  52.         $snappy = $this->get("knp_snappy.pdf");
  53.         $html = $this->renderView('PPPCanBundle:Reportes:perrosraza.html.twig', array('pagination' => $pagination, 'pagination1' => $pagination1));
  54.         //inicio generar pdf        
  55.         $filename = "custom_pdf_from_twig";
  56.         return new Response(
  57.             $snappy->getOutputFromHtml($html),
  58.             200,
  59.             array(
  60.                 'Content-Type' => 'application/pdf',
  61.                 'Content-Disposition' => 'inline; filename="'.$filename.'.pdf"'
  62.                 )
  63.             );
  64.     }
[/HIGHLIGHT]

Código HTML:
Ver original
  1.             <thead>
  2.                 <tr>
  3.                     <th width="50%">Genero</th>
  4.                     <th width="50%">Cantidad</th>
  5.                 </tr>
  6.             </thead>
  7.             <tbody>
  8.                 {% for genero in data['result']['generos'] %}
  9.                     <tr>
  10.                         <td>{{ genero['nombre'] }}</td>
  11.                         <td>{{ genero['cantidad'] }}</td>
  12.                     </tr>
  13.                 {% endfor %}
  14.             </tbody>
  15.         </table>

Alguien que por favor me ayude que estoy haciendo mal