PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #4306

No way to specify logic condition in nested joinAdd and whereAdd

Details

Request #4306No way to specify logic condition in nested joinAdd and whereAdd
Submitted2005-05-09 15:11 UTC
Fromej dot grace at imperial dot ac dot uk
StatusSuspended
PackageDB_DataObject
PHP Version4.3.10
OSLinux
Roadmaps(Not assigned)

Comments

[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)");