Bug #66621 [Fbk]: PDO::commit() bug

From: Date: Thu, 24 Apr 2014 06:25:37 +0000
Subject: Bug #66621 [Fbk]: PDO::commit() bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185406@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66621&edit=1

 ID:                 66621
 Updated by:         ab@php.net
 Reported by:        enrico_kaelert at kabelmail dot de
 Summary:            PDO::commit() bug
 Status:             Feedback
 Type:               Bug
 Package:            PDO MySQL
 Operating System:   Windows 7 64bit
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Hi,

I very appreciate your willingness to help, but still the script is not "10-20 lines
long". Please reduce it as much as possible, it is really hard to understand now what is your
issue and it would take to much time to debug such a big piece of code.

Many thanks.


Previous Comments:
------------------------------------------------------------------------
[2014-04-23 15:27:41] enrico_kaelert at kabelmail dot de

I changed the test script so the database and the table will be created.
I cant make it easier for you ;)

here is the script: http://pastebin.com/LyK5FUbN

------------------------------------------------------------------------
[2014-04-23 14:37:28] ab@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



------------------------------------------------------------------------
[2014-02-25 18:20:58] enrico_kaelert at kabelmail dot de

Forget about the part:
"
Weird:
If you look at the SELECT (# 4.) you can see that we get "fake"(?)-results back.
On every run the AUTO_INCREMENT counts up which is real - so those ids get lost.
"

Of curse the queries was sent to the sql server, auto_increment counted up (see docu dev.mysql.com).
The INSERTS/UPDATES/.. are not committed, so i guess we are getting the data out of temp tbls.

------------------------------------------------------------------------
[2014-02-01 00:56:37] enrico_kaelert at kabelmail dot de

Description:
------------
Trying to keep it short:

System:
Win7 64bit, xampp (MySQL Server Version: 5.6.14  PHP Version: 5.5.6)
Also tried that on a different system with (i think) PHP Version 5.8

The case:
using PDO to fire more than 1 INSERT INTO via PDO::beginTransaction() and PDO::commit()

The bug:
if i DO NOT set $stmt to "what ever", then the PDO::commit() has no effect.
But if i change $stmt to a string, a number or null - anything else but itself - then all INSERTs
are fired up.

Weird to describe.
Just see the test script at "# 3. ..." (line 43) where the "magic" happens.
To switch between the "working version" and the "bug version" simple change the
if(1) to if(0) ...


"bug version"
$stmt is a prepared query which was just executed.
Because we did a $dbh->beginTransaction(); we do now fire a $dbh->commit();
But ... no action has been taken @db - no inserts made.
This only seem to happen if you fire MORE than 1 INSERT at 1 query.


"working version"
The ONLY different here is that we set $stmt to something else.
$stmt is of curse the current prepared and executed query.
Now BEFORE we fire the $dbh->commit() we do: $stmt = 'anything else';
And - its magic - the following $dbh->commit() works :: all INSERTs are done.


Weird:
If you look at the SELECT (# 4.) you can see that we get "fake"(?)-results back.
On every run the AUTO_INCREMENT counts up which is real - so those ids get lost.


Thanks for you time - coulndt do it shorter.
Was looking into that problem for hours today with a friend =)


Test script:
---------------
detailed test script: http://pastebin.com/1QEcnPhM

Expected result:
----------------
explained in the description

Actual result:
--------------
explained in the description


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66621&edit=1


Thread (15 messages)

« previous php.bugs (#185406) next »