【发布时间】:2012-04-23 10:03:20
【问题描述】:
我有一个使用 CakePHP 的应用程序,我需要向表中插入一些数据行。我已经按照 CakePHP 书中的教程进行了操作,但它不起作用。
$this->Temporary->create();
$this->Temporary->set(
array(
'Temporary.position_id'=>$employeesAttribute[$arrCount][0]['EmployeeAttribute']['position_id'],
'Temporary.person_id'=>$employeesAttribute[$arrCount][0]['StatusEmployee']['person_id'],
'Temporary.job_id'=>$employeesAttribute[$arrCount][0]['Job']['id'],
'Temporary.unit_id'=>$employeesAttribute[$arrCount][0]['Unit']['id'],
'Temporary.person_code'=>$employeesAttribute[$arrCount][0]['StatusEmployee']['code'],
'Temporary.name'=>$employeesAttribute[$arrCount][0]['Person']['first_name'].' '.$employeesAttribute[$arrCount][0]['Person']['middle_name'].' '.$employeesAttribute[$arrCount][0]['Person']['last_name'],
'Temporary.job'=>$employeesAttribute[$arrCount][0]['Job']['short_desc']
)
);
$this->Temporary->save();
我使用了create() 方法,设置了变量并调用了save 方法,但是这段代码没有将数据保存到我的表中。这段代码有什么问题?
【问题讨论】:
-
保存后试试
var_dump($this->Temporary->invalidFields());。 -
结果还是一样,它没有将数据保存到表中..但是感谢您的回答。
-
这只是为了帮助你调试...
标签: cakephp cakephp-1.3