Php 如何在zf2中查看tablegateway执行的查询
这是我的控制器动作Php 如何在zf2中查看tablegateway执行的查询,php,sql,zend-framework2,zend-db,Php,Sql,Zend Framework2,Zend Db,这是我的控制器动作 public function updateAction() { // Retrieve parameters $event = $this->params()->fromRoute('event', null); $subUnitId = $this->params()->fromRoute('subunit', null); $employeeId = $this->params()->fromRou
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'],
));
}
每次我触发update函数时,它都会运行整个代码,但更新不起作用。我检查传递的数据和参数,它是正确的,所以现在我想检查我的模式创建的查询。提前谢谢。你可以试试这个
$update = new Sql\Update; // see [documentation][1] on how to build it
...
$this->tableGateway->getSql()->getSqlStringForSqlObject($update)
希望这能奏效;) 如果您只需要调试生成的查询。我建议使用Zend开发者工具&BjyProfiler。第一个插件在底部给你们一个调试栏。而第二个插件在工具栏上添加数据库查询。然后,您将在第页上执行sql查询列表 见类似问题: