ZF2-573: Can not not select columns from a table

Description

I'm trying to create a query where I don't want to select any columns from a table. This was possible in ZF1 by just passing an empty string where one would define the columns to be selected.

Example:


// in an AbstractTableGateway
$select = $this->select();
$select->from('my_table')
    ->columns(null) /* or some other way to note that I want NO columns from "my_table" */
    ->join(
        'my_other_table'
        'my_table.id = my_other_table.tbl_id',
        array('column1', 'column2')
    )

Expected query: SELECT my_other_table.column1, my_other_table.column2 FROM my_table INNER JOIN my_other_table ON ...

Actual query: - If I don't pass an array is passed to the columns() method, an error is thrown - If I pass an array with just a null, the query is SELECT my_table."" AS Expression1, my_other_table.column1, my_other_table.column2 FROM my_table INNER JOIN my_other_table ON ... - If I pass an array with just an empty string, the query is SELECT my_table."" AS "", my_other_table.column1, my_other_table.column2 FROM my_table INNER JOIN my_other_table ON ...

Similar for the third parameter of the join() method:


// in an AbstractTableGateway
$select = $this->select();
$select->from('my_table')
    ->columns(array('column1'))
    ->join(
        'my_other_table'
        'my_table.id = my_other_table.tbl_id',
        ''  /* or some other way to note that I want NO columns from "my_other_table" */
    )

Expected query: SELECT my_table.column1 FROM my_table INNER JOIN my_other_table ON ...

Actual query: - If I pass an array with just a null, the query is SELECT my_table."" AS Expression1, my_other_table.column1, my_other_table.column2 FROM my_table INNER JOIN my_other_table ON ... - If I pass an array with just an empty string, the query is SELECT my_table."" AS "", my_other_table.column1, my_other_table.column2 FROM my_table INNER JOIN my_other_table ON ...

Note that the first parameter for the columns() method must be an array, whereas the third parameter for the join() method does not need to be an array.

Comments

Using PDO_Mysql, forgot to mention.

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf2/issues/2598