1

我在我的模型中创建了一个函数,例如:

public function getAllMenuByOnlyActionPage($actionlot){

            $act  = trim($actionlot);
            $result = $this->tableGateway->select(function (Select $select) {
                        $select->where(array('status != ?' => 13))
                        ->where(array('action' => $act))
                        ->order('id ASC');
                    }); 
            $results = array();
            foreach ($result as $row) {
                $results[] = $row;
            }
            return $results;

        }  

当我尝试执行时,它会显示给我Notice: Undefined variable: act。我已经看到这个链接ZF2 tableGateway select但我想为这个函数设置参数。谢谢

4

1 回答 1

10

尝试

$result = $this->tableGateway->select(function (Select $select) use ($act)  {
                        $select->where(array('status != ?' => 13))
                        ->where(array('action' => $act))
                        ->order('id ASC');
                    }); 
于 2013-03-21T07:39:34.987 回答