Issues

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

Issue Type: Bug Created: 2012-09-19T10:37:51.000+0000 Last Updated: 2012-10-08T20:12:20.000+0000 Status: Closed Fix version(s): Reporter: Robert Basic (robertbasic) Assignee: Ralph Schindler (ralph) Tags: - Zend\Db

Related issues: Attachments:

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:

<pre class="highlight">
// 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:

<pre class="highlight">
// 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

Posted by Robert Basic (robertbasic) on 2012-09-19T10:48:14.000+0000

Using PDO_Mysql, forgot to mention.

Posted by Ralph Schindler (ralph) on 2012-10-08T20:12:20.000+0000

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts