Skip to content

Instantly share code, notes, and snippets.

@morozov
Created June 6, 2017 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morozov/ec49ee56aa93e942dfa547d81e770945 to your computer and use it in GitHub Desktop.
Save morozov/ec49ee56aa93e942dfa547d81e770945 to your computer and use it in GitHub Desktop.
<?php
/*
CREATE TABLE DB2_TEST
(
ID smallint DEFAULT 0
)
*/
$dsn = 'HOSTNAME=localhost;UID=db2inst1;PWD=Passw0rd;DATABASE=test';
$conn = db2_connect($dsn, null, null);
if (!$conn) {
echo db2_conn_errormsg(), PHP_EOL;
exit(1);
}
printf('PHP: %s' . PHP_EOL, phpversion());
printf('ibm_db2: %s' . PHP_EOL, phpversion('ibm_db2'));
$server = db2_server_info($conn);
printf('DB2 NAME: %s, VERSION: %s' . PHP_EOL, $server->DBMS_NAME, $server->DBMS_VER);
// without executing a query before the following one, the issue is not reproducible
$stmt = db2_prepare($conn, 'SELECT 1 FROM SYSIBM.SYSDUMMY1');
$result = db2_execute($stmt);
if (!$result) {
echo db2_stmt_errormsg(), PHP_EOL;
exit(1);
}
// the value of $true is the result of comparison of an array element value
// with the same value. if it's just literal true, the issue is not reproducible
$array = array('key' => 'value');
$true = $array['key'] == 'value';
$stmt = db2_prepare($conn, 'SELECT ID FROM DB2_TEST WHERE ID = ?');
$result = db2_execute($stmt, [$true]);
if (!$result) {
echo db2_stmt_errormsg(), PHP_EOL;
exit(1);
}
echo 'OK', PHP_EOL;
// [IBM][CLI Driver] CLI0111E Numeric value out of range. SQLSTATE=22003 SQLCODE=-99999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment