Re: DB_DataObject joinAdd
| From: | Alan Knowles | Date: | Fri, 18 Jun 2004 09:34:16 +0000 |
| Subject: | Re: DB_DataObject joinAdd | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13211@lists.php.net to get a copy of this message | ||
Finally got a chance to go through the code for joinAdd, and try and understand this a bit.
The forth argument to joinAdd is related to muliply joining a single table into another:
[user]
;id
friend = person:id
mother = person:id
$person->joinAdd($user,'LEFT',false,'friend');
should generate something like:
person LEFT JOIN user ON person.id = user.friend
It looks like you where trying to use the joinAdd argument to insert into the query..
To be honest the best way to do what you are trying is probably defining a method of the extended class:
function joinAddSeman()
$this->_joinAdd .= '...............';
}
Regards
Alan
Daniel Kopp wrote:
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 =-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.comkia_seminaranmeldung.pIDLEFT JOIN kia_fidpid ON kia_fidpid.pID = kia_adressen.pID LEFT JOIN kia_familienverband ON kia_familienverband.fID =kia_fidpid.fIDLEFT JOIN kia_adressen AS ad2 ON ad2.pID = kia_familienverband.pID LEFT JOIN kia_seminaranmeldung sem2 ON ( ad2.pID = sem2.pID ANDsem2.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