【发布时间】:2012-02-18 20:40:14
【问题描述】:
我有 CakePHP 控制器代码,它抛出以下错误“致命错误:调用非对象上的成员函数 create()”。
控制器代码如下:
if ($this->request->is('post')) {
$this->MonthlyReturn->create();
$this->MonthlyReturn->saveField('company_id', $cid); // Assign current company ID to this monthly return before saving
if ($this->MonthlyReturn->save($this->request->data)) {
$this->Session->setFlash(__('The monthly return has been saved'));
$this->redirect(array('action' => 'index'));
} else
{
$this->Session->setFlash(__('The monthly return could not be saved. Please, try again.'));
}
}
任何帮助将不胜感激。
【问题讨论】:
-
你能告诉我们你的控制器的第一行吗?
-
` App::uses('AppController', 'Controller'); /** * MonthlyReturns Controller * * @property MonthlyReturn $MonthlyReturn */ class MonthlyReturnsController extends AppController { var $uses = array('Employee','Company');`
标签: cakephp controller php