php - Zend Model Mapper fetchAll() 忽略我的 WHERE 子句

标签 php mysql zend-framework zend-db zend-db-table

在此代码中:

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $records = new Application_Model_Mapper_Record();
        $this->view->records = $records->fetchAll(array('type = ?' => 0));
    }


}

... fetchAll() 忽略我的 $where 子句并检索所有记录,而不是仅检索 type=0 的记录。

我尝试使用array('type = 0'),同样的问题。我在映射器 fetchAll() 方法中执行了 var_dump($where) ,但没有出现任何特殊情况,数组似乎没问题。

我该怎么办?我完全不知道为什么会这样做,而且我似乎是互联网上唯一遇到此问题的人。

最佳答案

$rowSet = $this->dbTable->fetchAll($where = null, $order = null, $count = null, $offset = null);

只需在映射器类中替换为 $rowSet = $this->dbTable->fetchAll($where, $order, $count, $offset); 即可。因为当您调用此方法时,您将 null 分配给方法参数。这是方法调用,而不是初始化。

关于php - Zend Model Mapper fetchAll() 忽略我的 WHERE 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18768026/

相关文章:

php - Wordpress:逐月获取帖子,布局问题

php - 如何计算PHP中两个日期之间的天数?

php - 无法将图像保存在 phpMyAdmin 数据库中,获取 [BLOB - 0 B]

php - Zend Routing::如何将所有请求发送到 application-> IndexController 到 application->module->store->IndexController

zend-framework - Zend Framework 1 的当前版本

php - 为什么大型框架忽略前提条件检查?

php - foreach 循环结果插入数据库

php - Laravel 关系重新加载

mysql - 有什么办法获取Mysql "rank"数据集

mysql - 插入时检测MySQL是否有重复