Zend Framework

Support JOIN ... USING syntax

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.5.0
  • Component/s: Zend_Db_Select
  • Labels:
    None
  • Fix Version Priority:
    Nice to Have

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.

Activity

Hide
Simon Mundy added a comment -

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.

Show
Simon Mundy added a comment - 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.
Hide
Bill Karwin added a comment -

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()
Show
Bill Karwin added a comment - 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()
Hide
Simon Mundy added a comment -

Resolved in trunk r8084

Show
Simon Mundy added a comment - Resolved in trunk r8084

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
3d
Original Estimate - 3 days
Remaining:
3d
Remaining Estimate - 3 days
Logged:
Not Specified
Time Spent - Not Specified