ZF-1845: Support JOIN ... USING syntax

Description

We can currently do this:


$select = $db->select()
  ->from('table1')
  ->join('table2', 'table1.column1 = table2.column1');

But we'd like to do it more conveniently like this:


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

So that the resulting SQL statement uses the {{USING}} syntax.

The two queries should produce the same result, assuming that your join condition in the first example is an equality between two columns that have the same name in both tables.

Note that {{USING}} is followed by a list of columns, comma-separated, inside parentheses.

Comments

Bill, how had you imagined the join type being specified? If the method signature is to follow the existing patterns of joinInner, joinFull, etc... then the join type might need to be supplied as a 4th parameter which may not be optimal.

There should be distinct methods, to remain consistent with the current convention in Zend_Db_Select, and also to make the class friendly to code-completion tools: * {{joinUsing()}} * {{joinLeftUsing()}} * {{joinRightUsing()}} * {{joinFullUsing()}}

Likewise, the same solution could be used for NATURAL joins for consistency (though no one has asked for more support of NATURAL joins). * {{joinNatural()}} * {{joinLeftNatural()}} * {{joinRightNatural()}} * {{joinFullNatural()}}

Resolved in trunk r8084