DB_DataObjects: Dont know how to multi join
| From: | Patrick Schuster | Date: | Sat, 14 Jun 2003 13:36:37 +0000 |
| Subject: | DB_DataObjects: Dont know how to multi join | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-5956@lists.php.net to get a copy of this message | ||
Hi all,
I've 3 tables,
locations (id, name, ...)
categories (id, name, ...)
loc_cat_xref (fk_loc_id, fk_cat_id)
As I want to have more than one category for one location and vice versa
I've created the 3rd table "loc_cat_xref" which contains the keys of the
"locations" and "categories" table. I've setup the
"*.links.ini"-File in
this way:
[loc_cat_xref]
fk_loc_id = locations:id
fk_cat_id = categories:id
Now I want to have something like this:
SELECT *
FROM locations AS loc
INNER JOIN loc_cat_xref AS lcx ON lcx.fk_loc_id = loc.id
INNER JOIN categories AS cat ON lcx.fk_cat_id = cat.id
or
SELECT * FROM locations AS loc, loc_cat_xref AS lcx, categories AS cat
WHERE lcx.fk_loc_id = loc.id AND lcx.fk_cat_id = cat.id
How can I do this with DataObject??
I've tried to "joinAdd" the tables "locations" and "loc_cat_xref"
and this
is no problem, but if I want to "joinAdd" "locations" and "categories"
I get
an error as there is no relation in the "*.links.ini"-File between this
tables. I've also downloaded the last CVS and there is a comment, that
DataObject now supports "mega join" but I don't know how to use this feature
and if this helps me.
Thanks in advance for any hints.
Bye
Patrick