|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-06-29 09:40 UTC] ian dot bjorhovde at gmail dot com
Description:
------------
When using stored procedures and db2_bind_param to bind variables to parameter markers, PHP will core dump. This is reproducible with:
PHP 4.3.9 (included with RHEL4) as well as current PHP (5.1.2)
and both
ibm_db2 1.2.1 and ibm_db2 1.2.3.
Note, using db2_execute() and passing IN parameters as an array works fine.
Reproduce code:
---------------
Example Stored Procedure:
create procedure test(IN i_tabschema varchar(128), OUT o_cnt smallint)
reads sql data
language sql
no external action
begin
select count(*)
into o_cnt
from syscat.tables
where tabschema = i_tabschema;
end@
PHP Code to call procedure:
<?php
$dbh = db2_connect('SAMPLE','','');
$sql = "call test(?, ?)";
$sth = db2_prepare($dbh, $sql);
$schema = "SYSCAT";
$count = 0;
db2_bind_param($sth, 1, "schema");
db2_bind_param($sth, 2, "count");
db2_execute($sth);
print "There are $count tables for schema $schema\n";
db2_close($dbh);
?>
Expected result:
----------------
Should output:
"There are 100 tables for schema SYSCAT"
Actual result:
--------------
[db2p01@kwaiken ~]$ php x.php
Content-type: text/html
X-Powered-By: PHP/4.3.9
There are 0 tables for schema SYSCAT
Segmentation fault (core dumped).
---
The backtrace isn't too useful, because PHP on my system was not compiled in debug mode, but this bug is easily reproducible.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 16:00:01 2025 UTC |
Please try the following changes and let us know if this fixes your issues: <?php $dbh = db2_connect('SAMPLE','',''); $sql = "call test(?, ?)"; $sth = db2_prepare($dbh, $sql); $schema = "SYSCAT"; $count = 0; db2_bind_param($sth, 1, "schema", DB2_PARAM_IN); db2_bind_param($sth, 2, "count", DB2_PARAM_OUT); db2_execute($sth); print "There are $count tables for schema $schema\n"; db2_close($dbh); ?>We have not been able to reproduce this issue with your sample script. We have set up the same stored procedure that you have given us and we used the following PHP script: <? $conn = db2_connect('sample', 'db2user', 'db2pass'); if ($conn) { $sql = "call test(?, ?)"; $sth = db2_prepare($conn, $sql); $schema = "SYSCAT"; $count = 0; db2_bind_param($sth, 1, "schema", DB2_PARAM_IN); db2_bind_param($sth, 2, "count", DB2_PARAM_OUT); db2_execute($sth); print "There are $count tables for schema $schema\n"; db2_close( $conn ); } else { print "\nnot connected\n"; } ?> This script provides us with the following result with no core dumps: There are 110 tables for schema SYSCAT Please provide more information or anything else to allow us to view your problem. Thank you.