Hello. I made a custom query in my cakephp 3.0, but when I wanna display the data in a table, the rows are empty. This is my function in controller:
public function estadisticas()
{
$conn = ConnectionManager::get('default');
$stmt = $conn->execute('SELECT c.nombre, c.idComplejo, t.canchaFK, count(*) AS cantidadTurnos FROM turno t inner join complejo c inner join ciudad cc inner join cancha ca inner join usuario u on t.canchaFK=ca.idCancha and c.idComplejo=ca.complejoFK and u.idUsuario=t.usuarioFK WHERE u.esComplejo=0 and cc.paisFK="1" and u.paisFK="1" and cc.idCiudad=c.ciudadFK and noAsistio=0 and fecha between "2016-07-01" and "2016-07-30" group by canchaFK');
$turnostotales = $stmt ->fetchAll('assoc');
$this->set('turnostotales',$turnostotales);
}
The query works perfect. Also, The page show me the table with 19 empty row (19 row is the result of the query).
This is the part of code where I display the data:
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th><?= $this->Paginator->sort('idComplejo', 'ID Complejo') ?></th>
<th><?= $this->Paginator->sort('canchaFK', '# Cancha') ?></th>
<th><?= $this->Paginator->sort('cantidadTurnos', 'Cantidad Turnos') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($turnostotales as $turnostotale): ?>
<tr>
<td><?= h($turnostotale->idComplejo) ?></td>
<td><?= h($turnostotale->canchaFK) ?></td>
<td><?= h($turnostotale->cantidadTurnos) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
Thanks for helping me!