gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 01:18:59 24 4
gpt4 key购买 nike

在此代码中:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com