ZF-5953: Support joining with multiple columns with joinUsing

Description

Currently, if you need to join on multiple columns, you cannot use joinUsing();

The join condition should accept an array of columns to join on.

SQL:


SELECT *
FROM table1
JOIN table2 USING (column1, column2)

Zend_Db_Select:


$select = $db->select()
  ->from('table1')
  ->joinUsing('table2', array('column1','column2'));

Originally suggested here: ZF-1845, but was only half implemented.

Comments

This issue still exists. Reproducing test case:


Index: tests/Zend/Db/Select/TestCommon.php
===================================================================
--- tests/Zend/Db/Select/TestCommon.php (revision 24794)
+++ tests/Zend/Db/Select/TestCommon.php (working copy)
@@ -1712,6 +1712,24 @@
     }
 
     /**
+     * @group ZF-5953
+     */
+    public function testJoinUsingAllowsSpecifyingMultipleColumnsViaAnArray()
+    {
+        $table_A = $this->_db->quoteTableAs('A');
+        $table_B = $this->_db->quoteTableAs('B');
+        $colOne  = $this->_db->quoteIdentifier('colOne');
+        $colTwo  = $this->_db->quoteIdentifier('colTwo');
+        
+        $s = $this->_db->select()->from('A')->joinUsing('B', array($colOne,$colTwo));
+        $this->assertContains(
+            "JOIN {$table_B} ON {$table_B}.{$colOne} = {$table_A}.{$colOne}"
+            . " AND {$table_B}.{$colTwo} = {$table_A}.{$colTwo}",
+            $s->assemble()
+        );
+    }
+
+    /**
      * @group ZF-3309
      */
     public function testJoinUsingUsesTableNameOfTableBeingJoinedWhenAliasNotDefined()

Fixed in trunk r24833