Joining multiple tables
Joining multiple tables
alan3222hk
Posts: 2Questions: 1Answers: 0
in Editor
Hi,
I have a table with this relationship:
one order -> one to many products -> one to one image
I can link the order and products with:
Editor::inst($db, 'orders')
->field(
Field::inst('orders.id'),
Field::inst('orders.name'),
Field::inst('orders.order_date')
)
->join(
Mjoin::inst('products')
->link('orders.id', 'orders_products.order_id')
->link('products.id', 'orders_products.product_id')
->field(
Field::inst('id'),
Field::inst('products', 'title'),
Field::inst('image_id')
)
)
);
How can I link the products.image_id to table 'images'?
thx!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Unfortunately the Mjoin does not have a left join method itself at the moment. The only way to do this with Editor's PHP libraries would be to create a VIEW based on your
products
table which does that left join and point the Mjoin at that VIEW (it will select just as if it a regular table).Allan
I see, thx Allan.