FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=4306&edit=1

ID: 4306
Updated by: alan@akbkhome.com
Reported By: ej dot grace at imperial dot ac dot uk
Summary: No way to specify logic condition in nested joinAdd
and whereAdd
-Status: Verified
+Status: Suspended
Type: Feature/Change Request
Package: DB_DataObject
Operating System: Linux
PHP Version: 4.3.10
Roadmap Versions:
New Comment:

-Status: Verified
+Status: Suspended
No patch available


Previous Comments:
------------------------------------------------------------------------

[2005-05-17 19:17:41] 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..

------------------------------------------------------------------------

[2005-05-09 11:11:01] 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)");
------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedApr 25, '10 at 11:04p
activeApr 25, '10 at 11:04p
posts1
users1
websitepear.php.net

1 user in discussion

Alan: 1 post

People

Translate

site design / logo © 2021 Grokbase