php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36605 query with the named placeholders insert wrong data (PDO_OCI)
Submitted: 2006-03-03 15:02 UTC Modified: 2016-03-08 01:40 UTC
From: grzeh at mikronika dot pl Assigned:
Status: Not a bug Package: PDO OCI
PHP Version: 5.1.2 OS: GNU/Linux
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: grzeh at mikronika dot pl
New email:
PHP Version: OS:

 

 [2006-03-03 15:02 UTC] grzeh at mikronika dot pl
Description:
------------
I have a problem in PDO extension (PDO_OCI driver) when I use 'insert' statement with the named placeholders. I insert two different strings into two fields. Execution of 'select'  statement returns one the same 'word' in two fields.

Similar problem I'h found in 'Select' statement with the named placeholders.

This 'bug' occured in PHP version greater then 5.1.0RC7-dev (snapshot 2005-11-21 07:30), where all works correctly. In versions 5.1.1, 5.1.2 and the latest (php5.1 2006-03-03 09:30) I have above errors.

I use --with-pdo-oci=instantclient,/usr,10.1.0.3 switch during compilation and I connect with Oracle server in 8.1.7 version. I run this test case under PDO_PGSQL driver and it works properly.

Reproduce code:
---------------
$x = new PDO("oci:dbname=xxx", 'scott', 'tiger');
$x->query("CREATE TABLE test(name VARCHAR2(100), value VARCHAR2(100))");
//insert statement:
$stmt = $x->prepare("INSERT INTO test (name, value) VALUES (:name, :value)");
$t = array(":name"=>"foo",":value"=>"bar");
$stmt->execute($t);

//test select statement:
$row = $x->query("SELECT name, value FROM test");
print("name: ".$row["NAME"]." value:".$row["VALUE"]);

//'bindParam' version of 'insert' statement:
$stmt = $x->prepare("INSERT INTO test (name, value) VALUES (:name, :value)");
$stmt->bindParam(":name", $the_name, PDO::PARAM_STR, 32);
$stmt->bindParam(":value", $the_value, PDO::PARAM_STR, 32);
$the_name = "foo";
$the_value = "bar";
$stmt->execute();

//select statement:
$stmt = $x->prepare("SELECT name, value FROM test WHERE name = :name AND value = :value");
$the_name = 'foo';
$the_value = 'bar';
$stmt->execute(array(":name"=>$the_name,":value"=>$the_value));
if($row = $stmt->fetch())
   print_r($row);
else
   print "no rows";
if($row["NAME"]!=$the_name or $row["VALUE"]!=$the_value)
 {
   print("Error: selected value is different from condition");
 }
else
 {
   print("OK");
 }



Expected result:
----------------
name: foo value: bar
Array
(
    [NAME] => foo
    [0] => foo
    [VALUE] => bar
    [1] => bar
)
OK

Actual result:
--------------
name: bar value: bar
"Segmentation fault" error
Array
(
    [NAME] => bar
    [0] => bar
    [VALUE] => bar
    [1] => bar
)
Error: selected value is different from condition

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-06 14:44 UTC] developit at mail dot ru
just another incarnation of bug #36318
 [2006-03-06 14:48 UTC] tony2001@php.net
Dup of bug #36318.
 [2016-03-08 01:40 UTC] sixd@php.net
-Package: PDO related +Package: PDO OCI
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 15:01:28 2019 UTC