php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73206 oci_bind_by_name/oci_execute doesn't work properly
Submitted: 2016-09-30 02:58 UTC Modified: 2016-10-13 04:46 UTC
From: sergei dot solomonov at gmail dot com Assigned:
Status: Duplicate Package: OCI8 related
PHP Version: 7.1.0RC3 OS: Ubuntu 15.04
Private report: No CVE-ID:
 [2016-09-30 02:58 UTC] sergei dot solomonov at gmail dot com
Description:
------------
Tested with 7.09 and 7.1.0RC3 on Ubuntu 15.04.
Default php.ini-development config was used.

Configure command:
'./configure' '--enable-zip' '--enable-intl' '--with-oci8' '--enable-dbase' '--disable-cgi' '--with-apxs2=/usr/local/apache/bin/apxs' '--enable-opcache' '--enable-sigchild' '--enable-mbstring' '--with-xsl' '--with-gd' '--with-config-file-scan-dir=/usr/local/apache/conf' '--with-openssl' '--with-curl' '--with-zlib' '--enable-timezonedb'

Example below leads to incorrect result. In case bind value 8 or more chars length returns `false`, if less than 8 - returns correct result.
It may be related with https://bugs.php.net/bug.php?id=73085.
For now, its impossible to work with PHP 7 and Oracle DB looks very unstable and buggy. Can't use any php7 version in prod.

Test script:
---------------
class Statement {
    public $resource;
    function __construct($sql) {
        $conn = oci_connect(getenv('db_login'), getenv('db_pwd'), getenv('db_host'));
        $this->resource = oci_parse($conn, $sql);
    }

    public function errorHandler($severity, $message, $file = '', $line = 0) {
        var_dump($message, 0, $severity, $file, $line);
    }

    function execute() {
        set_error_handler([$this, 'errorHandler']);
        oci_execute($this->resource);
        restore_error_handler();
    }

    function bindParams(array $bindParams = []) {
        foreach ($bindParams as $bvn => &$bvv) {
            oci_bind_by_name($this->resource, $bvn, $bvv);
        }
    }

    function fetch() {
        return oci_fetch_array($this->resource);
    }
}


$stmt = new Statement("select * from dual where :param = 'xxxxxxxx'");
$stmt->bindParams(['param' => 'xxxxxxxx']);
$stmt->execute();
var_dump($stmt->fetch());


Expected result:
----------------
array(2) {
  [0]=>
  string(1) "X"
  ["DUMMY"]=>
  string(1) "X"
}

Actual result:
--------------
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-13 04:46 UTC] sixd@php.net
-Status: Open +Status: Duplicate
 [2016-10-13 04:46 UTC] sixd@php.net
Seems fixed by the patch in bug #71148.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC