note 118073 added to function.db2-connect

From: Date: Tue, 29 Sep 2015 13:16:17 +0000
Subject: note 118073 added to function.db2-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-203874@lists.php.net to get a copy of this message
As of 09/29/2015 when using the ibm_db2 driver and specifying an invalid library list with the 'i5_libl' option, the connection will be successfully created but with a default library list. What happens is the connection is made and THEN the library list is attempted to be changed. The connection will be a success but the library list change will fail without "db2_conn_error()" or "db2_conn_errormsg()" reporting anything and a default library list will be used. However, "db2_stmt_error()" and "db2_stmt_errormsg()" will register with a value. Also if error reporting is enable, the warning will be output to the screen. This is not a bug, rather intended behavior according to Zend (I opened a ticked) and depending on which library list is used/swapped could lead to major problems (development VS production). I stumbled upon this behavior when an anomaly (which I still can't explain) was imploding my library list with the character 'Z'. I realized I was in my development environment but accessing production data as a result. Going forward I will make sure to add this additional check for good measure. See below to recreate behavior: <?php ini_set("display_errors", 1); $systemName = 'systemName'; $userID = 'userName'; $password = 'password'; $options['i5_libl'] = implode('Z', array( 'INVALID', 'LIB', 'LIST', 'IMPLODED', 'WITH', 'THE', 'LETTER', 'Z' )); $options['i5_naming'] = DB2_I5_NAMING_ON; $conn = db2_connect($systemName, $userID, $password, $options); //This line causes "ini_set("display_errors", 1)" to dislay this warning on the screen: //Warning: db2_connect(): Statement Execute Failed in /PATH/TO/FILE/test.php on line 58 if (db2_stmt_error()) { //Evaluates to true echo "error ID: " . (db2_stmt_error()); //Displays error code: 38501 echo "<br>error message: " . (db2_stmt_errormsg()); //Displays: Trigger program or external routine detected an error. SQLCODE=-443 } echo "<br />|".db2_conn_error()." ||| ".db2_conn_errormsg()."|<br />"; //Only "| ||| |" is displayed print_r($conn); //A resource ID is displayed echo "<br />"; if(isset($conn) && $conn === true){ echo "Boolean true<br />"; //never executes, but not expected since either false or a resource ID should be returned. //Plus it is clear $conn contains a resource ID from above. } if(isset($conn) && $conn == true){ echo "Non-Boolean true 2<br />"; //This always executes regardless of an accurate library list or not //I suppose "if($conn)" would evaluate to non-boolean true so this makes sense. } if(isset($conn) && $conn == "true"){ echo "String true"; //Never executes, but not expected. } if(isset($conn) && $conn === false){ echo "Boolean false<br />"; //never executes because the connection itself was a success. //If invalid credentials were provided this executes. } if(isset($conn) && $conn == false){ echo "Non-Boolean false 2<br />"; //never executes because the connection itself was a success. //Added this here because I was unsure if a boolean false would be returned or not. //If invalid credentials were provided this executes as well. } if(isset($conn) && $conn == "false"){ echo "String false"; //never executes because the connection itself was a success. //Added this here because I was unsure if a String "false" would be returned } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 24.38.13.195 ---- Manual Page -- http://php.net/manual/en/function.db2-connect.php Edit -- https://master.php.net/note/edit/118073 Del: integrated -- https://master.php.net/note/delete/118073/integrated Del: useless -- https://master.php.net/note/delete/118073/useless Del: bad code -- https://master.php.net/note/delete/118073/bad+code Del: spam -- https://master.php.net/note/delete/118073/spam Del: non-english -- https://master.php.net/note/delete/118073/non-english Del: in docs -- https://master.php.net/note/delete/118073/in+docs Del: other reasons-- https://master.php.net/note/delete/118073 Reject -- https://master.php.net/note/reject/118073 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203874) next »