我正在使用cakephp開發一個Web應用程序。我有一個函數,我想使用cakephp的save()方法將一些數據保存到模型中。但每當我要保存數據,我得到這種錯誤:在CakePHP中通過save()方法保存數據時遇到問題
Fatal error: Call to undefined method App::save() in /httpdocs/MyApp/app/Controller/AppsController.php on line 71
任何人都知道我在這裏失蹤。我的控制器的功能如下:
public function add_app($id=null){
$this->layout = 'user';
if (!empty($id)) {
$this->request->data['App']['id_users'] = $_SESSION['edit_user_id'];
$this->request->data['App']['id_store'] = $id;
$this->request->data['App']['id_unique_app'] = $Guid;
$this->request->data['App']['tx_app_name'] = $data['results'][0]['trackName'];
$this->request->data['App']['tx_platform'] = 'iOS';
$this->request->data['App']['nu_price'] = $data['results'][0]['price'];
$this->request->data['App']['da_created'] = date("Y-m-d H:i:s");
if ($this->App->save($this->request->data)) {
$this->Session->setFlash('The selected app has been added successfully.');
$this->redirect(array('action' => 'index'));
}
}
}
在此先感謝。
@rikesh ..這是可能保存數據而不指定型號? –
@amit - 我希望凱文向你解釋了同樣的情況:) – Rikesh