Bug #10240 [Opn]: Composite key fix for #4266 not applied both ways

From: Date: Fri, 02 Mar 2007 06:20:18 +0000
Subject: Bug #10240 [Opn]: Composite key fix for #4266 not applied both ways
References: 1  Groups: php.pear.webmaster 
Request: Send a blank email to pear-webmaster+get-5738@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=10240&edit=1 ID: 10240 User updated by: dsanders at baselinesolutions dot com dot au Reported By: dsanders at baselinesolutions dot com dot au Status: Open Type: Bug Package: Bug System Operating System: Irrelevant PHP Version: 5.2.1 New Comment: 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) { Previous Comments: ------------------------------------------------------------------------ [2007-03-02 01:16:31] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=10240&edit=1

« previous php.pear.webmaster (#5738) next »