Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Zend_Db_Statement_DB2 returns null for static field
    primarykey
    data
    text
    <p>I am building my SQL statement through a PHP API, and then passing it through a module that connects to our database (DB2).</p> <p>My issue: a <strong>static field</strong> (sales_type) is returning null when passing the SQL through a Zend_Db_Statement_DB2 module. Running the SQL directly on our AS400 (command line), it works properly. When I pass the same SQL through the DB2 module the "sales_type" field is null for all rows.</p> <p>A simplified version of the query:</p> <pre><code>SELECT 'discount' "sales_type", sum(sales_type1) "sales" FROM salesTable UNION SELECT 'promotion' "sales_type", sum(sales_type2) "sales" FROM salesTable </code></pre> <p>Expected/Desired results with fictiscious sales (what is also returned on command line):</p> <pre><code>sales_type sales discount 12345 promotion 6789 </code></pre> <p>Returned results when SQL passed through DB2 module:</p> <pre><code>sales_type sales null 12345 null 6789 </code></pre> <p>The PHP code used to execute <em>select queries</em> is listed below:</p> <pre><code> public static function ExecuteSelect($sql) { $adapter = new Zend_Db_Adapter_Db2(Zend_Registry::get('config')-&gt;resources-&gt;multidb-&gt;as400) //Prepare the SQL Statement $sqlStmt = new Zend_Db_Statement_DB2($adapter, $sql); $sqlStmt-&gt;execute(); $rows = $sqlStmt-&gt;fetchAll(); return $rows; } </code></pre> <p>Can anyone give me more insight as to the cause of this issue and how to fix it? Also, I'm not looking for a post-processing php work-around. Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload