这是我的控制器动作
public function updateAction()
{
// Retrieve parameters
$event = $this->params()->fromRoute('event', null);
$subUnitId = $this->params()->fromRoute('subunit', null);
$employeeId = $this->params()->fromRoute('employee', null);
$status = $this->params()->fromRoute('status', 0);
// Construct data array for database update
$data = array(
'os_event_id' => $event,
'sub_unit_id' => $subUnitId,
'employee_id' => $employeeId,
'created_by' => $this->getCurrentUser(),
'status' => $status,
);
// Update status to database
$this->getOsfTable()->updateStatus($data);
$url = $this->getRequest()->getHeader('Referer')->getUri();
return $this->redirect()->toUrl($url);
}
这是我的模特
public function updateStatus($data)
{
$this->tableGateway->update(array(
'status' => $data['status'],
'created_by' => $data['created_by'],
), array(
'os_event_id' => $data['os_event_id'],
'employee_id' => $data['employee_id'],
'sub_unit_id' => $data['sub_unit_id'],
));
}
每当我触发更新功能时,它会遍历整个代码,但更新不起作用。我检查传递的数据和参数,它是正确的所以现在我想检查我的模式的创建查询。在此先感谢。
答案 0 :(得分:0)
你可以试试这个
$update = new Sql\Update; // see [documentation][1] on how to build it
...
$this->tableGateway->getSql()->getSqlStringForSqlObject($update)
希望这会奏效;)
答案 1 :(得分:0)
如果您只需要调试生成的查询。我建议使用Zend Developer Tools& BjyProfiler。第一个插件在底部给你一个调试栏。第二个插件在工具栏中添加数据库查询。然后你会在页面上执行sql查询列表。
看到类似的问题: How to view db queries generated by TableGateway in Zend Framework 2