Php 使用TableGateway选择函数设置参数显示错误未定义变量
我在模型中创建了一个函数,如:Php 使用TableGateway选择函数设置参数显示错误未定义变量,php,zend-framework2,Php,Zend Framework2,我在模型中创建了一个函数,如: public function getAllMenuByOnlyActionPage($actionlot){ $act = trim($actionlot); $result = $this->tableGateway->select(function (Select $select) { $select->where(array('status
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;
}
当我尝试执行时,它的show me注意:未定义变量:act。我已经看到这个链接,但我想为这个函数设置参数。谢谢试试看
$result = $this->tableGateway->select(function (Select $select) use ($act) {
$select->where(array('status != ?' => 13))
->where(array('action' => $act))
->order('id ASC');
});
试一试
如果你有这个参考链接,请给我链接。如果你有这个参考链接,请给我链接。