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  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2010-04-26 03:58 UTC
Package:
Bug Type:
Summary:
From: ej dot grace at imperial dot ac dot uk
New email:
PHP Version: Package Version: OS:

 

 [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] alan_k
This really needs adding to a DB_DataObject_Join Class, - as the join code is far to complex at present.. For the time being It's best do more complex joins like this using function myjoin() { $this->_join .= '......' } or similar..
 [2010-04-26 03:58 UTC] alan_k (Alan Knowles)
-Status: Verified +Status: Suspended
No patch available