From:             grzeh at mikronika dot pl
Operating system: GNU/Linux
PHP version:      5.1.2
PHP Bug Type:     PDO related
Bug description:  query with the named placeholders insert wrong data (PDO_OCI)

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

-- 
Edit bug report at http://bugs.php.net/?id=36605&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36605&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36605&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36605&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36605&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=36605&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36605&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36605&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36605&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36605&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36605&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=36605&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=36605&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36605&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36605&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36605&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36605&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36605&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36605&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36605&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36605&r=mysqlcfg

Reply via email to