I have 3 table: ["Order", "Order_to_goods", "Goods"]
I want to get of all participants of many-to-many relationships, by Order_ID, to can do something like that:
$Order = Doctrine::getTable('Order')->findOneById( 1 );
$Order ->loadReleated('Goods');
foreach( $Order->Goods as $product){...}
But it isn't work. Having tried everything I despair. Can you give me some helpfull council.
Addition
To get a nested values need a few operations:
$this->orderObject->loadReference('StoreOrderToItem');
foreach($this->orderObject->StoreOrderToItem as $OrderToItem)
{
$OrderToItem->loadReference('StoreItem');
}
And few queries to DB, to get complete object:
SELECT s.order_id AS s__order_id, s.goods_id AS s__goods_id, s.count AS s__count, s.price AS s__price FROM store_order_to_item s WHERE (s.order_id IN (?))
SELECT s.id AS s__id, s.section_id AS s__section_id, s.payment_strategy_id AS s__payment_strategy_id, s.name AS s__name, s.title AS s__title, s.description AS s__description, s.price AS s__price, s.creation_date AS s__creation_date, s.status AS s__status, s.sort AS s__sort FROM store_item s WHERE (s.id = ?)
SELECT s.id AS s__id, s.section_id AS s__section_id, s.payment_strategy_id AS s__payment_strategy_id, s.name AS s__name, s.title AS s__title, s.description AS s__description, s.price AS s__price, s.creation_date AS s__creation_date, s.status AS s__status, s.sort AS s__sort FROM store_item s WHERE (s.id = ?)
What if there is not only one or two rows in DB, there is thousands rows. There is a necessity to combine all in one query (with LEFT JOIN
operands). How can do this, If all relations are put right?
Doctrine Documentation failed to disclose this problem for me. I hope you could help me.
PS: Sorry for my English, I write this above 30 minutes =))