|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-12-05 18:06 UTC] iliaa@php.net
[2006-12-13 01:00 UTC] php-bugs at lists dot php dot net
[2010-01-02 05:53 UTC] tadiyya at sapplica dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 20:00:01 2025 UTC |
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