php - 过去 6 小时内所有事件的计数 Zend 框架

标签 php mysql zend-framework

我想知道如何统计过去 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/

相关文章:

php - PHP混淆中的比较运算符 "=="

php - 使用 password_hash 函数恢复密码

php - 如何使用 Zend Framework 和 PHPUnit 成功创建项目?

php - Zend Framework select() 给出意外的 SQL

zend-framework - 原则2 Zend框架命名空间 Controller

php - 在图像旁边环绕文字

PHP - 检测字符串之间的空格

python - 无法在 sqlalchemy 中引用外键

php - 子查询 PHP 显示 0 结果

php - 如何处理(转义)mysqlclient 中的 % 符号(C 库)