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 に答える