私はリンクテーブルと多対多の関係を持っています。以下の(簡略化された)スキーマを参照 チュートリアル(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;
しかし、それdoesntの仕事、$ oProductは、オブジェクトが、の各プロパティを表す文字列のように見えるdoesntのため、製品クラス。 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を見逃しました。私はこの教義のことを初めて知りましたが、私の考えは正しいので、自分のロケティモデルから直接商品を取り出せるはずです。ありがとう、ジェレミー! – tomvo