大家好,我在cakehp2.x框架中开发了一个应用程序。我已经写了一个代码更新&使用以下代码保存到数据库中:
public function editpackage($id=null)
{
$this->layout='dashboard';
$this->loadModel('Survay');
if (!$id) {
throw new NotFoundException(__('Your request is invalid'));
}
$get_survay_id = $this->Survay->findById($id);
if (!$get_survay_id) {
throw new NotFoundException(__('Your request is invalid'));
}
if ($this->request->is(array('post', 'put'))) {
$this->Survay->id = $id;
$this->request->data['Survay']['modifydate']=DboSource::expression('NOW()');
if ($this->Survay->save($this->request->data)) {
$this->Session->setFlash('Your Survay is successfully updated','default',array('class'=>'alert alert-success'));
return $this->redirect(array('controller'=>'Users','action'=>'detailspackage'));
}
}
if (!$this->request->data) {
$this->request->data = $get_survay_id;
}
}
我得到:
Non-static method DboSource::expression() should not be called statically, assuming $this from incompatible context
这是因为您使用的是PHP 5.4或更高版本,其中E_STRICT已成为E_ALL的一部分。
选项1
您可以通过在app/config/core.php中修改错误配置来从错误报告中删除~E_STRICT:
Configure::write('Error', array(
'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_STRICT & ~E_DEPRECATED,
'trace' => true
));
选项2
代替
DboSource::expression('NOW()');
您可以拨打
$this->Model->getDataSource()->expression('NOW()');