Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Request #4306 No way to specify logic condition in nested joinAdd and whereAdd
Submitted: 2005-05-09 15:11 UTC
From: ej dot grace at imperial dot ac dot uk Assigned:
Status: Suspended Package: DB_DataObject
PHP Version: 4.3.10 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-05-09 15:11 UTC] ej dot grace at imperial dot ac dot uk
Description: ------------ When combining joinAdd and whereAdd conditions the whereAdd conditions on the seperate objects are combined implicitly with AND in the generated SQL. For example $country->whereAdd('name = \'Germany\''); $person->joinAdd($country); $institution->whereAdd('name = \'test\''); $person->joinAdd($institution); $person->fetch(); Combines the condition on $country and $institution with 'AND' so that it would fetch people where their names are 'test' AND they are in a country with the name 'Germany' Reproduce code: --------------- The following diff adds an optional joinAdd logic parameter which is passed through to the subsequent whereAdd calls. This allows one to carry out the join add mentioned above returning records with 'Germany' as the name in the country table OR 'test' as the name of the institution. 18c18 < * @version CVS: $Id: DataObject.php,v patch 2005/05/09 16:02:00 graceej Exp $ --- > * @version CVS: $Id: DataObject.php,v 1.353 2005/04/20 07:50:01 alan_k Exp $ 2822,2824d2821 < * @param optional $joinLogic string The whereAdd logic to use when adding whereAdd conditions < * to nested joins default is 'OR' (default is 'AND') < * 2829c2826 < function joinAdd($obj = false, $joinType='INNER', $joinAs=false, $joinCol=false, $joinLogic='AND') --- > function joinAdd($obj = false, $joinType='INNER', $joinAs=false, $joinCol=false) 2836d2832 < 3016c3012 < $this->whereAdd("{$joinAs}.{$ofield}={$table}.{$tfield}",$joinLogic); --- > $this->whereAdd("{$joinAs}.{$ofield}={$table}.{$tfield}"); 3055c3051 < )),$joinLogic); --- > ))); 3059c3055 < $this->whereAdd("{$joinAs}.{$kSql} = {$obj->$k}",$joinLogic); --- > $this->whereAdd("{$joinAs}.{$kSql} = {$obj->$k}"); 3063c3059 < $this->whereAdd("{$joinAs}.{$kSql} = 0",$joinLogic); --- > $this->whereAdd("{$joinAs}.{$kSql} = 0"); 3078c3074 < $this->whereAdd("($cond)",$joinLogic); --- > $this->whereAdd("($cond)");

Comments

 [2005-05-17 23:17 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2010-04-26 03:58 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!