ID: 37646
Updated by: [EMAIL PROTECTED]
Reported By: dipeshkhakhkhar at gmail dot com
-Status: Open
+Status: Assigned
Bug Type: PDO related
Operating System: Windows XP
PHP Version: 5CVS-2006-05-31 (snap)
-Assigned To:
+Assigned To: wez
Previous Comments:
------------------------------------------------------------------------
[2006-05-31 02:41:26] dipeshkhakhkhar at gmail dot com
Description:
------------
Hi,
When i tried to execute the following query using PDO execute method,
it failed and gave me the following error. I have tried on two
different version php 5.1.2 an php 5.2
My query had a strign with the following value.
'AUX:2:2\\?\ACPI#PNP0C0C#2&daba3ff&0#{4afa3d53-74a7-11d0-be5e-00a0c9062857}'
Error:
HY093 SQLSTATE[HY093]: Invalid parameter number: mixed named and
positional parameters
OS: Windows XP
Database: db2
Extensions to use pdo from php.
extension=php_pdo.dll
extension=php_pdo_odbc.dll
When i directly insert into my database the same query works fine but
from php it gives me the error. If you need more information please
informe me.
Thanks!
Regards,
Dipesh
Reproduce code:
---------------
DB stmt.
-------
CREATE SEQUENCE foo_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE
CREATE TABLE foo( foo_id BIGINT NOT NULL, foo_value varchar(252));
php statements:
--------------
<?php
$dbName = ""; // your database name
$port = "50000"; $hostName ="127.0.0.1";
$user = '' ; // user name
$pass = ''; // password
$db = new PDO('odbc:DRIVER={IBM DB2 ODBC
DRIVER};hostname='.$hostName.';PORT='.$port.';DATABASE='.$dbName.';PROTOCOL=TCPIP',
$user, $pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->beginTransaction();
$testsql = "insert into foo (foo_id, foo_value) values ( nextval for
foo_seq,
'AUX:2:2\\?\ACPI#PNP0C0C#2&daba3ff&0#{4afa3d53-74a7-11d0-be5e-00a0c9062857}')";
try {
$stmt = $db->prepare($testsql);
if(!$stmt->execute()){
echo "error in execute statement ";
}else
echo "Successful execute ";
}
catch(PDOException $e) {
echo "statement failed in execute method ".$testsql."\n ";
echo "Error is ".$e->getCode()." " . $e->getMessage() ."\n ";
}
$db->commit();
?>
Expected result:
----------------
It should run the query and insert the values into the database without
throwing any exception.
Actual result:
--------------
It throws an exception which is as follows:
statement failed in execute method insert into foo (foo_id, foo_value)
values ( nextval for foo_seq,
'AUX:2:2\?\ACPI#PNP0C0C#2&daba3ff&0#{4afa3d53-74a7-11d0-be5e-00a0c90
62857}')
Error is HY093 SQLSTATE[HY093]: Invalid parameter number: mixed named
and positional parameters
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37646&edit=1