Home » Database » DB_DataObject » Bug #10240
Composite key fix for #4266 not applied both ways
Details
| Submitted | 2007-03-02 06:16 UTC |
|---|---|
| From | dsanders at baselinesolutions dot com dot au |
| Status | Bogus |
| Package | DB_DataObject |
| PHP Version | 5.2.1 |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2007-03-02 06:16 UTC] dsanders at baselinesolutions dot com dot au
Description:
------------
The fix for #4266 was only applied when retrieving the keys of the joinee object, and not when retrieving the keys for the joiner object.
Test script:
---------------
links.ini:
[test_b]
fk_a,fk_b=test_a:key_a,key_b
$test_a = DB_DataObject::factory('test_a');
$test_b = DB_DataObject::factory('test_b');
$test_b->joinAdd($test_a);
DB_DataObject::debugLevel(1);
$test_b->find();
Expected result:
----------------
DO_Test_b: find:
DO_Test_b: QUERY: SELECT *
FROM test_b
INNER JOIN test_a ON test_a.key_a=test_b.fk_a AND test_a.key_b=test_b.fk_b
Actual result:
--------------
DO_Test_b: find:
DO_Test_b: QUERY: SELECT *
FROM test_b
INNER JOIN test_a ON test_a.key_a,key_b=test_b.fk_a,fk_b
[2007-03-02 06:20 UTC] dsanders at baselinesolutions dot com dot au
Here's a patch (just paste the same lines from the previous foreach):
@@ -3111,6 +3111,19 @@ class DB_DataObject extends DB_DataObjec
foreach ($links as $k => $v) {
/* link contains {this column} = {linked table}:{linked column} */
$ar = explode(':', $v);
+
+ // Feature Request #4266 - Allow joins with multiple keys
+
+ $links_key_array = strpos($k,',');
+ if ($links_key_array !== false) {
+ $k = explode(',', $k);
+ }
+
+ $ar_array = strpos($ar[1],',');
+ if ($ar_array !== false) {
+ $ar[1] = explode(',', $ar[1]);
+ }
+
if ($ar[0] == $obj->__table) {
if ($joinCol !== false) {
if ($k == $joinCol) {
[2007-03-02 07:18 UTC] dsanders at baselinesolutions dot com dot au
Sorry, I'm an idiot, the correct package is DB_DataObject
[2007-03-02 07:21 UTC] dsanders at baselinesolutions dot com dot au
Added package version
[2007-03-02 07:41 UTC] dsanders at baselinesolutions dot com dot au
I see now it was fixed in CVS about a week ago.