Set Parameter with TableGateway Select Function show error undefined variable-Collection of common programming errors

i create a function in my model like :

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;

        }  

When i try to execute then its show me Notice: Undefined variable: act. I already see this link ZF2 tableGateway select but i want to set parameter for this function. Thanks

  1. Try

    $result = $this->tableGateway->select(function (Select $select) use ($act)  {
                            $select->where(array('status != ?' => 13))
                            ->where(array('action' => $act))
                            ->order('id ASC');
                        }); 
    

Originally posted 2013-11-10 00:12:10.