我在我的模型中创建了一个函数,如:
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,但我想为这个函数设置参数。感谢
答案 0 :(得分:10)
尝试
$result = $this->tableGateway->select(function (Select $select) use ($act) {
$select->where(array('status != ?' => 13))
->where(array('action' => $act))
->order('id ASC');
});