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 #7590

UNIONS

Details

Request #7590UNIONS
Submitted2006-05-09 16:11 UTC
Fromlamengual at sitrack dot com
StatusFeedback
PackageDB_DataObject
PHP Version4.3.10
OSWindows XP
Roadmaps(Not assigned)

Comments

[2006-05-09 16:11 UTC] lamengual at sitrack dot com

Description:
------------
It would be nice if possible to make querys with UNIONS like for example

SELECT name FROM table1
UNION
SELECT name FROM table2

We can do this with the query method but its not neat specially when querys are complex, below ill put an example of a desired usage.

Test script:
---------------

Expected result:
----------------
SOLUTION 1:

$personA = DB_DataObject::factory('person');
$personB = DB_DataObject::factory('person');

$personA->name = "Bob";
$personB->name = "Dillan";

$personsUnion->union ( $personA, $personB );
$personsUnion->orderBy ( 'person.name' );
$personsUnion->find();

....

Actual result:
--------------
SOLUTION 2:

$personA = DB_DataObject::factory('person');
$personB = DB_DataObject::factory('person');

$personA->name = "Bob";
$personB->name = "Dillan";

$queryA = $personA->getQuery();
$queryB = $personB->getQuery();

$union = DB_DataObject();
$union->query ( $queryA . ' UNION ' . $queryB );

...