ZF-2316: Allow NULL columns in Select object

Issue Type: Improvement Created: 2007-12-15T18:46:57.000+0000 Last Updated: 2008-02-26T12:55:57.000+0000 Status: Resolved Fix version(s): - 1.0.4 (26/Feb/08)

Reporter: Eran Galperin (erangalp) Assignee: Thomas Weidner (thomas) Tags: - Zend_Db_Select

Related issues: Attachments:


A simple modification to the Select object __toString() method can allow the setting of NULL columns when constructing the SQL string. Specifically changing: (line 137)

<pre class="highlight">
 list($correlationName, $column, $alias) = $columnEntry;
 if ($column instanceof Zend_Db_Expr) {
         $columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
} else { 


<pre class="highlight">
list($correlationName, $column, $alias) = $columnEntry;
         $columns[] = 'NULL';
} else if ($column instanceof Zend_Db_Expr) {
         $columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
} else {

would allow setting NULL columns by passing a 'null' value as an array value in the column correlation array.

I needed this modification since I sometimes use the Select object to construct SQL strings to be used as parts in a larger UNION query. In a UNION, the number of columns for each composing SELECT query has to match, sometimes requiring setting columns as NULL. Others might find this useful for various reasons.


Posted by Eran Galperin (erangalp) on 2008-01-20T21:34:12.000+0000

Is a patch commit of this planned? Or do I need to continue patching Zend_Db_Select with new releases...

Posted by Thomas Weidner (thomas) on 2008-02-08T14:35:56.000+0000

Integrated with SVN-7869

Have you found an issue?

See the Overview section for more details.


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

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