1

CakePHP を使用したアプリケーションがあり、データの行をテーブルに挿入する必要があります。CakePHP book のチュートリアルに従いましたが、うまくいきません。

$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 メソッドを呼び出しましたが、このコードではデータがテーブルに保存されません。このコードの何が問題になっていますか?

4

1 に答える 1

2
$this->Temporary->create();
$data = 
    array(
        'Temporary' => array(
            'position_id'=>$employeesAttribute[$arrCount][0]['EmployeeAttribute']['position_id'],
            'person_id'=>$employeesAttribute[$arrCount][0]['StatusEmployee']['person_id'],
            'job_id'=>$employeesAttribute[$arrCount][0]['Job']['id'],
            'unit_id'=>$employeesAttribute[$arrCount][0]['Unit']['id'],
            'person_code'=>$employeesAttribute[$arrCount][0]['StatusEmployee']['code'],
            'name'=>$employeesAttribute[$arrCount][0]['Person']['first_name'].' '.$employeesAttribute[$arrCount][0]['Person']['middle_name'].' '.$employeesAttribute[$arrCount][0]['Person']['last_name'],
            'job'=>$employeesAttribute[$arrCount][0]['Job']['short_desc']
        )
    )
);
$this->Temporary->save($data);
于 2012-04-23T10:14:56.567 に答える