Home » Database » DB_DataObject » Bug #7590
UNIONS
Details
| Request #7590 | UNIONS |
|---|---|
| Submitted | 2006-05-09 16:11 UTC |
| From | lamengual at sitrack dot com |
| Status | Feedback |
| Package | DB_DataObject |
| PHP Version | 4.3.10 |
| OS | Windows 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 );
...