2012-04-23 7 views
1

私はCakePHPでアプリケーションを持っているので、テーブルにデータ行を挿入する必要があります。私はCakePHPの本のチュートリアルに従ってきましたが、うまくいきません。私はcreate()メソッドを使用している新しい行にデータを保存する

$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(); 

は、変数を設定し、保存する方法を呼び出しますが、このコードは私のテーブルにデータを保存しません。このコードで何が問題になっていますか?

+0

保存後に 'var_dump($ this-> Temporary-> invalidFields());'を試してください。 – deceze

+0

結果は同じですが、データをテーブルに保存しません。答えに感謝します。 – user1290932

+0

これはちょうどあなたを助けることになっています*デバッグ* ... – deceze

答えて

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); 
+0

ありがとうthecodeparadox ...あなたのコードは動作しています...非常にありがとう.. – user1290932

関連する問題