|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77846 Binding Error(db2_bind_param)
Submitted: 2019-04-04 11:58 UTC Modified: 2019-04-18 02:10 UTC
From: ushida100 at gmail dot com Assigned:
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 7.2.16 OS: IBM i V7R2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ushida100 at gmail dot com
New email:
PHP Version: OS:


 [2019-04-04 11:58 UTC] ushida100 at gmail dot com
PHP Version 7.2.15
Module Name : ibm_db2
Module release : 2.0.6-zs1

Running db2_exec with db2_bind_param causes an error.
It's not a class and runs fine.
But when used in class, an error occurs.

This happened in previous versions, but it was resolved at that time.
Variable scope problem ?

The message is as follows.

PHP Warning:  db2_execute(): Value Not Bound in foo.class.php on line 51
PHP Warning:  db2_execute(): Binding Error 3 in foo.class.php on line 51

This occurs with the following code.


$hoge = new Hoge();
$row2 = $hoge->getRow();

class Hoge {
    public function getRow(){
        $db = db2_connect("DB2" ,"USER" ,"PASS");
        $sql = "set schema PHPDEMO" ;
        $result = db2_exec($db,$sql);
        $sql="select * from empl where code = ?";
        $result = db2_prepare($db,$sql);
        $code2 = 110 ;
        db2_bind_param($result ,1 ,"code2",DB2_PARAM_IN);
        //**** ERROR
        $stmt = db2_execute($result) ;
        $row = db2_fetch_assoc($result) ;
        return $row ;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-17 09:33 UTC] ushida100 at gmail dot com
-Operating System: IBMi +Operating System: IBM i V7R2
 [2019-04-17 09:33 UTC] ushida100 at gmail dot com
I tried ibm_db2 in some environments.
PHP V7.2 fails when executing "_php_db2_hash_find_ind ()".
In PHP V7.1, it can be executed normally.
Variables of Class or Function will be "NULL" in the following steps.

static int _php_db2_hash_find_ind(char * varname, int varlen, zval **temp, zval ***bind_data, zend_array ** symbol_table_used TSRMLS_DC)
    int rc = FAILURE;
    zend_array * symbol_table_local; /* php 5.3+, php 7+ */

    /* Fetch data from symbol table (local scope) */
    symbol_table_local = zend_rebuild_symbol_table();
    *temp =  zend_hash_str_find_ind(symbol_table_local, varname, varlen );
    /*************** Not really NULL!!!! **************/
    if (*temp != NULL) {
        *bind_data = temp;
        *symbol_table_used = symbol_table_local;
        rc = SUCCESS;
    /* Fetch data from symbol table (global scope ... mmm??) */
    } else {
        *temp =  zend_hash_str_find_ind(&EG(symbol_table), varname, varlen );
        if (*temp != NULL) {
            *bind_data = temp;
            *symbol_table_used = &EG(symbol_table);
            rc = SUCCESS;

Is it a problem with the Zend API?
 [2019-04-18 02:09 UTC] ushida100 at gmail dot com
I tried to compile ibm_db2-2.0.8 in PHP7.1 environment.
It worked fine with the db2_bind_param function.
I think this seems to be a problem due to PHP 7.2.
I have found that this is not a problem with ibm_db2, so I close this problem.
 [2019-04-18 02:10 UTC] ushida100 at gmail dot com
-Status: Open +Status: Closed
 [2019-04-18 02:10 UTC] ushida100 at gmail dot com
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Aug 04 04:01:24 2021 UTC