#27521 [Opn->Fbk]: ODBC_Prepare forcing execution prior to ODBC_Execute with MySQL/MyODBC DB
| From: | sniper@php.net | Date: | Mon, 08 Mar 2004 11:44:44 +0000 |
| Subject: | #27521 [Opn->Fbk]: ODBC_Prepare forcing execution prior to ODBC_Execute with MySQL/MyODBC DB | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-56090@lists.php.net to get a copy of this message | ||
ID: 27521
Updated by: sniper@php.net
Reported By: getzeroedin at hotmail dot com
-Status: Open
+Status: Feedback
Bug Type: ODBC related
Operating System: Win2000 Prof
PHP Version: 4.3.4
New Comment:
If same code works with Mssql, what makes you think it's bug in PHP but
not in mysql/myodbc ?
Previous Comments:
------------------------------------------------------------------------
[2004-03-07 16:41:43] getzeroedin at hotmail dot com
Description:
------------
When using PHP 4.3.4 and the Unified ODBC Functions (ODBC_PREPARE &
ODBC_EXECUTE) to issue an "INSERT" SQL statement, the prepare is
forcing the execution of an "INSERT" statement on the ODBC_PREPARE and
on the ODBC_EXECUTE resulting in "Duplicate key error". The Insert
statement being prepared uses placeholders (e.g. ?). Hence, the
PREPARE statement inserts NULLS where those placeholders exist while
the EXECUTE statement attempts to validly execute the INSERT statement,
but an erroneous record already has been inserted during the PREPARE
resulting in a "duplicate key error". I am using MySQL 4.0.18 and
MyODBC 3.51.06. This worked fine on MS SQLServer but I want to use
MySQL for obvious reasons.
Reproduce code:
---------------
/*
PHP 4.3.4
MySQL 4.0.18
MyODBC 3.51.06
Win2K Professional
*/
$params[] = 1033;
$params[] = "Test Label";
$query = "Insert into LABELS (id, code, label) Values (1,?,?)";
$RID = ODBC_Prepare($CID,$query);
ODBC_Execute($RID,$params);
Expected result:
----------------
Insert is successful using placeholders.
Actual result:
--------------
Warning: odbc_execute(): SQL error: [MySQL][ODBC 3.51
Driver][mysqld-4.0.18-max-debug]Duplicate entry '1' for key 1, SQL
state 23000 in SQLExecute in c:\source\test.php on line 14
A record will be inserted into LABELS during the prepare:
id=1
code=NULL
label=NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27521&edit=1