我想知道如何统计过去 6 小时内的所有事件。
我的数据库中有两个表 eventdate (datetime) 和 id (int) 。
我在模型中定义了特定的数据库和表:
Event.php:
<?php
class Model_Event extends Zend_Db_Table_Abstract
{
protected $_name = 'event';
protected $_schema = 'db';
}
但是我的 Controller 有一些问题。我知道我的表格和页面中有一些行必须显示 10 个调用,但始终不显示任何事件
SummaryController:
public function indexAction()
{
$eventModel= new Model_Event();
$select = $eventModel->select()->where ('eventdate > NOW() - INTERVAL 6 HOUR') ;
$rowCount_op = count($select);
if ($rowCount_op >1) {
echo $rowCount_op.'calls';
}
else
echo 'no events';
}
}
最佳答案
试试这个:
$select = $eventModel->fetchAll($eventModel->select()->where("eventdate > DATE_SUB(CURDATE(), INTERVAL 6 HOUR)" ));
关于php - 过去 6 小时内所有事件的计数 Zend 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28213027/