I have a many-to-many relation with a linked table. See (simplified) schema below. Created according to the tutorial (http://www.symfony-project.org/doctrine/1_2/en/05-Data-Fixtures#chapter_05_many_to_many)
The schema imports/builds correct and phpmyadmin shows the foreign keys correct. I'm under the impression that afterwards in the 'locatie' module's indexSuccess template i can call:
foreach($locatie->getProducts() as $oProduct):
echo $oProduct->naam;
endforeach;
But that doesnt work, because $oProduct doesnt appear to be an object but a string representing each property in the product class. The foreach simply loops the properties of the first product instead of the product list. Anybody any advice?
Şema
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