ID:               45120
 Updated by:       mbecc...@php.net
 Reported By:      morrisdavidd at gmail dot com
 Status:           Open
 Bug Type:         PDO related
 Operating System: Linux
 PHP Version:      5.3
 New Comment:

The bug is reproducible only with the MySQL driver when using emulated
prepared queries, which is the default. I've tested PgSQL and Sqlite and
both work as expected.

There's also a pdo_mysql test for it, already marked as XFAIL:
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/bug_45120.phpt?view=markup


Previous Comments:
------------------------------------------------------------------------

[2009-07-28 07:10:10] morrisdavidd at gmail dot com

Sorry for the late reply,

I just duplicated this bug in PHP 5.3

Cheers,
David)

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

[2009-05-03 01:00:13] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2009-04-25 15:03:12] j...@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



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

[2008-10-14 13:06:53] fel...@php.net

I can't reproduce it.

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

[2008-07-03 13:32:37] u...@php.net

On the first look this seems to be a PDO not a PDO_MYSQL (or any other
driver) bug. 

>From pdo_stmt.c, static PHP_METHOD(PDOStatement, execute), around line
450:


if (PDO_PLACEHOLDER_NONE == stmt->supports_placeholders) {
                /* handle the emulated parameter binding,
         * stmt->active_query_string holds the query with binds
expanded and 
                 * quoted.
         */

                ret = pdo_parse_params(stmt, stmt->query_string,
stmt->query_stringlen,
                        &stmt->active_query_string, 
&stmt->active_query_stringlen
TSRMLS_CC);

[...]
}

For some drivers, PDO assigns the return value of its
pdo_parse_params() function to ret. And then the code flow continues and
eventually the driver gets called to execute the statement (depending on
the driver features):

if (stmt->methods->executer(stmt TSRMLS_CC)) {
                if (stmt->active_query_string && stmt->active_query_string !=
stmt->query_string) {
                        efree(stmt->active_query_string);
                }
                stmt->active_query_string = NULL;
                if (!stmt->executed) {
                        /* this is the first execute */

                        if (stmt->dbh->alloc_own_columns && !stmt->columns) {
                                /* for "big boy" drivers, we need to allocate 
memory to fetch
                                 * the results into, so lets do that now */
                                ret = pdo_stmt_describe_columns(stmt TSRMLS_CC);
                        }

                        stmt->executed = 1;
                }

                if (ret && !dispatch_param_event(stmt, PDO_PARAM_EVT_EXEC_POST
TSRMLS_CC)) {
                        RETURN_FALSE;
                }
                        
                RETURN_BOOL(ret);
        }

ret (returned ny pdo_parse_params()) will be overwritten only on the
first execution. Upon subsequent executions the driver cannot set ret.
You get a bool(false) because pdo_parse_params() has returned 0 (=
success) and the return value of PDO_MYSQL has been ignored.

Maybe it should read like this:

if (ret = stmt->methods->executer(stmt TSRMLS_CC)) {



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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/45120

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

Reply via email to