에 나는이 있습니다. 사람에게업데이트 관련 테이블 케이크
$savedPerson = $this->Person->saveAll($this->request->data, array('validate'=>'first'));
삽입 :
나는 케이크가 자동으로이 일을하기 때문에 제공되는 다른 두 테이블의 외래 키 기본 테이블의 ID로 긴뿐만 아니라 관련 테이블을 업데이트 생각 테이블과 다른 두 개의 테이블은 잘 관련이 있습니다.다른 두 테이블도 어떻게 업데이트합니까?
편집 : 모델 관계에 대한 :
사람 모델 :
public $hasMany = array(
'PersonParts' => array(
'className' => 'Part',
'foreignKey' => 'part_person_id'
),
'PersonColors' => array(
'className' => 'Color',
'foreignKey' => 'color_person_id'
)
);
제품 모델 :
public $belongsTo = array(
'PartPerson' => array(
'className' => 'Person',
'foreignKey' => 'part_person_id'
)
);
색상 모델 :
public $belongsTo = array(
'ColorPerson' => array(
'className' => 'Person',
'foreignKey' => 'color_person_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
$ this-의 16,
편집 2
위해서 var_dump> 요청 -> 데이터
array(3){
["Person"]=>array(4){
["person_user_id"]=>string(1)"3"
["person_name"]=>string(9)"Britney"
["person_category_id"]=>string(2)"16"
["visibility"]=>string(1)"1"
["person_id"]=>string(1)"71"
}
["PersonParts"]=>array(1){
[0]=>array(3){
["part_name"]=>string(4)"hands"
["quantity"]=>string(1)"2"
["part_part_type_id"]=>string(1)"1"
}
}
["PersonColors"]=>array(2){
[0]=>array(4){
["color_name"]=>string(3)"blue"
["test_field1"]=>string(1)"8"
["test_field2"]=>string(1)"9"
["position"]=>int(1)
}
[1]=>array(2){
["color_name"]=>string(5)"red"
["position"]=>int(2)
}
}
}
주 : 이것은 위해서 var_dump 만 보이고있다 [ "person_id로"] => 캐릭터 (1) "71"인 아래 배열을 추가 필드로 사용하면 케이크가 업데이트되지 않고 삽입되지 않습니다. PersonPart와 PersonColors 아래에 person_id가 표시되지 않습니다. 다른 두 테이블에 대한 업데이트는 어떻게해야합니까?
Person, Personcolor 및 PersonParts 모델의 관계와 관련된 코드를 붙여 넣을 수 있습니까? – cornelb
@cornelb 좋아, "편집"후 질문에 모델 관계를 게시했습니다 – Leah
저장하기 전에 $ this-> request-> data의 var_dump를 게시 할 수 있습니까? –