[英]Save is not working as expected in cakephp 1.2
using cakePhp for an existing product they have old version 1.2. 对于现有产品使用cakePhp,它们具有旧版本1.2。 I just started using CakePhp.
我刚刚开始使用CakePhp。 I tried to save some data to the table.
我试图将一些数据保存到表中。 here is my code.
这是我的代码。
function add(){
//echo $id;
pr($this->data);
if(!empty($this->data)){
$this->User->create();
if($this->User->save($this->data)){
debug($this->User->validationErrors);
exit();
$this->Session->setFlash("Data saved man");
$this->redirect(array('action'=>'index',2));
}
}
}
Below is debug data. 以下是调试数据。
Array
(
[user] => Array
(
[first_name] => hello
[last_name] => man
[email] => lrer@drei.cm
[password] => 123
[created_at] => Array
(
[month] => 01
[day] => 17
[year] => 2014
[hour] => 08
[min] => 56
[meridian] => am
)
[modified_at] => Array
(
[month] => 01
[day] => 17
[year] => 2014
[hour] => 08
[min] => 56
[meridian] => am
)
)
)
app\controllers\users_controller.php (line 36)
Array
(
)
(default) 0 query took ms
Nr Query Error Affected Num. rows Took (ms).
I have no clue why data is not saving to database. 我不知道为什么数据没有保存到数据库。 I need to get it work for version 1.2.
我需要使它适用于1.2版。 thanks
谢谢
I think user
key should have capital U as User
. 我认为
user
密钥应具有大写U作为User
。 Check your view code to make sure that the model passed to $form->create('User')
not 'user'
检查您的视图代码,以确保模型传递给
$form->create('User')
而不是'user'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.