어머니 테이블에 외래 키를 저장하는 솔루션을 찾으려면 많은 시간이 필요합니다. symfony 1.4와 embed 관계를 사용하려고합니다 (ihDoctrineEasyEmbeddedRelationsPlugin도 있음).외부 키가 포함 관계로 저장되지 않음
내가 여기 심포니 문서
을 읽을 때 http://www.symfony-project.org/more-with-symfony/1_4/en/06-Advanced-Forms
스키마은 : embedRelation의 모습
Product:
columns:
name: { type: string(255), notnull: true }
price: { type: decimal, notnull: true }
ProductPhoto:
columns:
product_id: { type: integer }
filename: { type: string(255) }
caption: { type: string(255), notnull: true }
relations:
Product:
alias: Product
foreignType: many
foreignAlias: Photos
onDelete: cascade
: 내 경우
// lib/form/doctrine/ProductForm.class.php
public function configure()
{
// ...
$this->embedRelation('Photos');
}
내가 할 수 없습니다 어쨌든, 반대로, 제품에는 관계 키가 있습니다. 아베 그런 일 :
Product:
columns:
name: { type: string(255), notnull: true }
price: { type: decimal, notnull: true }
photoid: { type: integer }
ownerid: { type: integer }
relations:
Photo:
local: photoid
foreign: id
type: one
Owner:
local: ownerid
foreign: id
type: one
Photo:
columns:
id : { type: integer }
filename: { type: string(255) }
caption: { type: string(255), notnull: true }
owner:
columns:
id : { type: integer }
firstname: { type: string(255) }
lastname: { type: string(255), notnull: true }
과 embedRelation :
// lib/form/doctrine/ProductForm.class.php
public function configure()
{
// ...
$this->embedRelation('Photo');
$this->embedRelation('Owner');
}
그리고 이름이나 가격 같은 제품이 관련 위젯 만되지는 형태로 업데이트 할 수 있지만 정보는 사진 및 소유자 테이블에서 오는 .
새 양식을 저장할 때 사진 및 소유자 개체가 테이블에 저장되고 ID는 시퀀스로 만들어집니다. 문제는 제품이 절대로 업데이트되지 않는다는 것입니다. photoid와 ownerid는 여전히 null로 유지됩니다. 사진과 소유자가 포함 된 양식과 비슷합니다. 루트 양식 뒤에 저장됩니다.
이 경우 embedrelation을 사용할 수 있습니까? 루트 폼이 processForm에 저장 될 때 제품 테이블에 외래 키를 저장하는 올바른 방법은 무엇입니까? 트릭이 무슨 도움이됩니까? PhotoForm.class.php에서
usefields을 읽을 수는 표시입니다 : "sfForm :: useFields()가 1.3 심포니 할 수있는 새로운 기능입니다 개발자는 양식에서 사용할 필드와 표시 할 순서를 정확하게 지정할 수 있으며 숨겨진 필드 이외의 모든 필드는 양식에서 제거됩니다. " 두 테이블의 ID는 양식에 숨겨져 있습니다. 내가 가지고있는 문제는 표시가 아닌 외래 키를 저장하는 것입니다. – philcaba