Php zend无法在phtml中显示多个差异记录

Php zend无法在phtml中显示多个差异记录,php,zend-framework,Php,Zend Framework,in view.phtml 我每人有这两个 $where = array('status' => 1); $this->view->active = $user->fetchAll($where); $where1 = array('status' => 0); $this->view->inactive = $user->fetchAll($where1); 上述代码仅返回非活动和非活动的活动记录。在这些方面我需要更改什么。您可能应该使用

in view.phtml

我每人有这两个

   $where = array('status' => 1);
$this->view->active = $user->fetchAll($where);
$where1 = array('status' => 0);
$this->view->inactive = $user->fetchAll($where1);

上述代码仅返回非活动和非活动的活动记录。在这些方面我需要更改什么。

您可能应该使用
占位符语法来更正您的
WHERE
子句:

foreach($this->active as $active){
    echo $active->uid;
    echo $active->uname;
}

foreach($this->inactive as $inactive_va){
    echo $inactive_va->uid;
    echo $inactive_va->uname;
}
但是,请注意,不推荐将
WHERE
子句直接提供给
fetchAll()
。请参见页面上的警告。最好使用
Zend\u Db\u Table\u Select
对象修改查询

您的第一个查询将如下所示:

$where = array('status = ?' => 1);
$where1 = array('status = ?' => 0);

您是否尝试过打印($this->active)返回什么?不清楚这里出了什么问题。您是说您两次获得相同的用户列表,而这些用户来自活动用户列表还是foreach,非活动用户不返回任何内容,而您只获得第一个foreach的输出?您确定数据库中有状态为0的用户吗?当我放置print\r时,它显示两个用户的相同记录,第二个“$where1=array('status'=>0);$this->view->inactive=$user->fetchAll($where1);”未应用。但在foreach中,我仅使用“非活动”字段,对于该数组,活动记录显示为多个和第二个how?->where(“price=?”,$price)->where('product_name=?”,$prod);请确认此项或此$select=$db->select()->from('products',array('product_id','product_name','price')->where('price>?',$minimumPrice)->where('price<?',$MAXIMMUMPRICE');确切地两者都应该是正确的。关于如何将多个
WHERE
子句与
组合,请参见我的回答:
$user->fetchAll(
    $user->select()->where('status = ?', 1);
);