DB_DataObject joinAdd
| From: | Daniel Kopp | Date: | Wed, 16 Jun 2004 13:52:20 +0000 |
| Subject: | DB_DataObject joinAdd | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13182@lists.php.net to get a copy of this message | ||
Hi!
Excited I found out that DB_DataObject's joinAdd supports a
defineable column now. But - I cannot understand why I cannot do
whatever I want with it. I keep getting a
"You cannot target a join column in the 'link from' table
(kia_seminaranmeldung). Either remove the fourth argument to joinAdd
() ((ad2.pID=semanm.pID)), or alter your links.ini file."
That is not really a help but rather very annoying as it will
probably force me to use a raw query once more (which is uncool as I
cannot configure that optionally as good as a real DB_DataObject
query)
I do this:
$ad2->joinAdd($semanm2, 'LEFT','semanm2','(ad2.pID=semanm2.pID)');
$verb->joinAdd($ad2, 'LEFT', 'ad2');
$fidpid->joinAdd($verb, 'LEFT');
$ad->joinAdd($fidpid, 'LEFT');
$semanm->joinAdd($ad);
which is supposed to Link semanm2 to ad2 but instead semanm is linked
to ad (which is the same table that is used twice in the query - the
second time renamed to ad2)
I would like to get:
SELECT foo, bar, baz
FROM kia_seminaranmeldung
INNER JOIN kia_adressen ON kia_adressen.pID =
kia_seminaranmeldung.pID
LEFT JOIN kia_fidpid ON kia_fidpid.pID = kia_adressen.pID
LEFT JOIN kia_familienverband ON kia_familienverband.fID =
kia_fidpid.fID
LEFT JOIN kia_adressen AS ad2 ON ad2.pID = kia_familienverband.pID
LEFT JOIN kia_seminaranmeldung sem2 ON ( ad2.pID = sem2.pID AND
sem2.sID =
kia_seminaranmeldung.sID )
I know that looks strange but it gives me the right result ... and
you haven't seen the where statement :-)
How can I tell DB_DataObject to either link the table properly or use
a real custom column? Of course semanm2 and ad2 have a link entry in
my database.ini ... Maybe the renameing of the tables confuses the
object ...
regards
Daniel