링크 된 테이블과 다 대 다 관계가 있습니다. 아래 (단순화 된) 스키마를 참조하십시오. 자습서 (http://www.symfony-project.org/doctrine/1_2/en/05-Data-Fixtures#chapter_05_many_to_many)에 따라 생성symfony 객체 대신 다 대다 관계 루프 속성
스키마 가져 오기/빌드가 정확하고 phpmyadmin이 외부 키가 올바른 것으로 표시됩니다. 내가 나중에 'locatie'모듈의 indexSuccess 템플릿에 내가 호출 할 수 인상을 해요 :
foreach($locatie->getProducts() as $oProduct):
echo $oProduct->naam;
endforeach;
하지만 나던 일을, $ oProduct 객체하지만 각 속성을 나타내는 문자열로 표시 나던 때문에 제품 클래스. foreach는 단순히 제품 목록 대신 첫 번째 제품의 속성을 반복합니다. 아무도 조언 없습니까?
스키마
Locatie:
connection: doctrine
tableName: locatie
columns:
locatie_id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
naam:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
LocatieProduct:
connection: doctrine
tableName: locatie_product
columns:
locatie_product_id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
locatie_id:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
product_id:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
relations:
Locatie:
local: locatie_id
foreign: locatie_id
foreignAlias: LocatieProducts
onDelete: CASCADE
Product:
local: product_id
foreign: product_id
foreignAlias: LocatieProducts
onDelete: CASCADE
Product:
connection: doctrine
tableName: product
columns:
product_id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
naam:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
이것은 문제를 해결합니다. 많은 사람들과 refClass를 놓쳤습니다. 나는이 모든 교리의 내용에 익숙하지 않지만 내 생각은 옳았다. 나는 나의 locatie 모델로부터 직접 제품을 가져올 수 있어야한다. Jeremy에게 감사드립니다! – tomvo