From:             getzeroedin at hotmail dot com
Operating system: Win2000 Prof
PHP version:      4.3.4
PHP Bug Type:     ODBC related
Bug description:  ODBC_Prepare forcing execution prior to ODBC_Execute with 
MySQL/MyODBC DB

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 bug report at http://bugs.php.net/?id=27521&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27521&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27521&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27521&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27521&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27521&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27521&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27521&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27521&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27521&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27521&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27521&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27521&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27521&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27521&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27521&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27521&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27521&r=float

Reply via email to