Re: Re: DB_DATAOBJECT extended join ...
| From: | Alan Knowles | Date: | Mon, 15 Mar 2004 06:59:39 +0000 |
| Subject: | Re: Re: DB_DATAOBJECT extended join ... | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11292@lists.php.net to get a copy of this message | ||
$table1 = DB_DataObject::factory('table1');
$table2 = DB_DataObject::factory('table2');
$table1->joinAdd($table2,'LEFT');
$table1->whereAdd("table2.bar = $value"); // should escape $value
$table1->find();
// assuming you have set up links.ini to map
[table1]
foo = table2:foo
the other condition should be valid as part of the general where condition.
otherwise, just resort to $table1->query(.....)
Regards
Alan
Daniel Kopp wrote:
Hi!-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.comeh.. - not quite sure what you are trying to do there... AFAIK - the on condition in the join will only do a single a=b.sorry - I don't get that ...Daniel Kopp wrote:What I want to do: I want to get links from table1 to table2 but only if these links exist with table2.bar set to a certain value. If there is no such column I want to get it filled with NULL ... (different from using WHERE which would not give back anything ...) As this works nicely in mySQL I wonder how to get it in DB_DataObject regards DanielHi! Actually I wonder whether this is allowed but it works: how can I do: SELECT * FROM table1 LEFT JOIN table2 ON (table1.foo = table2.foo AND table2.bar=$value) Does it have a name? Or is that called "wrong" or "bad style" or "lucky that it works" or something?