【发布时间】:2016-08-07 22:07:32
【问题描述】:
我在我的 cakephp 3.0 中进行了自定义查询,但是当我想在表格中显示数据时,行是空的。这是我在控制器中的功能:
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);
}
查询完美。此外,该页面向我显示了具有 19 个空行的表(19 行是查询的结果)。
这是我显示数据的代码部分:
<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>
谢谢你帮助我!
【问题讨论】:
标签: php cakephp cakephp-3.0 cakephp-3.x