Re: writing Joins using DB_DataObject 1.7.10
| From: | Kurund Jalmi | Date: | Mon, 21 Mar 2005 12:53:56 +0000 |
| Subject: | Re: writing Joins using DB_DataObject 1.7.10 | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18196@lists.php.net to get a copy of this message | ||
hi all
i also tried manupulating
$this->_join, but still not working? i am nor sure if method i used was correct.. tables are same as below..
can anyone help me please...
any instructions how to manupulate $this->_join ???
regards
kurund jalmi
Kurund Jalmi wrote:
Thanks all, "LEFT" worked fine for me.. (instead of LEFT OUTER JOIN) BUT still have problem writing multiple condition for "addJoin" i have 3 tables main, location and place i created object for those three tables.. i did the following things. $location->joinAdd($place); $location->whereAdd($this->tableName().'.id = 1'); $main->joinAdd($location); $main->whereAdd($main->tableName().'.id = '.$location->tableName().'.id'); after firing the sql.. when i checked my logs i found that.. condition for 'ON' clause was in 'WHERE' clause it doesnnot adds to 'ON' clause of that join.. regards kurund jalmi Justin Patrin wrote:On Sat, 19 Mar 2005 19:39:39 +0530, Kurund JalmiLEFT is the same as LEFT OUTER.<kurund@webaccess.co.in> wrote:hello, i am working on DB_DataObject 1.7.10. i have few querries on writing joins: 1. How can i write "left outer joins" using DB_DataObjects? i found out that addjoin has only 3 options "LEFT, RIGHT AND INNER"..2. If i want to write condition in ON clause of JOIN, i use the follwing method: $this->joinAdd($location); $this->whereAdd($this->id = $location->id); this works fine.I doubt it, that's not the right syntax at all. This should work: $this->whereAdd($this->tableName().'.id = '.$location->tableName().'.id');but if i want to write multiple condition in ON clause for example: $this->joinAdd($location); $this->whereAdd($this->id = $location->id AND $location->state = 1); then only first condition is considered.. second is ignored..Again, probably because that's not the right syntax at all. $this->whereAdd($this->tableName().'.id = '.$location->tableName().'.id AND '.$location->tableName().'.state = 1'); Of course, adding a where isn't quite the same as actually adding to an on clause, especially when the join is OUTER. If you actually want to add to the ON clause you'll have to edit $this->_join manually. This is somewhat hard to do, though, especially if you're doing multiple joins.