$where = array('status' => 1);
$this->view->active = $user->fetchAll($where);
$where1 = array('status' => 0);
$this->view->inactive = $user->fetchAll($where1);在view.phtml中
我有这两个森林
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;
}上面的代码只返回非活动和非活动的活动记录。我必须在这些上做些什么改变。
发布于 2013-03-26 16:51:12
您可能应该使用?占位符语法来使您的WHERE子句正确:
$where = array('status = ?' => 1);
$where1 = array('status = ?' => 0);但是,请注意,不建议直接向fetchAll()提供WHERE子句。请参阅Zend_Db_Table documentation上的警告。最好使用Zend_Db_Table_Select对象修改您的查询。
您的第一个查询将如下所示:
$user->fetchAll(
$user->select()->where('status = ?', 1);
);https://stackoverflow.com/questions/15631663
复制相似问题