[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-internals
Subject:    [PHP-DEV] Re: [PATCH] mysqli #35203 / #48065 Eliminate special case for
From:       Michael G Schwern <schwern () pobox ! com>
Date:       2009-04-26 7:47:02
Message-ID: 49F41176.8010508 () pobox ! com
[Download RAW message or body]

Andrey Hristov wrote:
> could you show how you want to express that in PHP code that will work
> with calling prepared statements. How the API should work? (Example PHP
> code that uses the new API).

Sorry, I don't understand what you're asking.

There is no changes to the mysqli API in this patch, its just a bug fix for
mysqli::query().  If you're asking for a demonstration of the bug, there's a
phpt test in the patch and demo code in the bugs.
http://bugs.php.net/bug.php?id=35203
http://bugs.php.net/bug.php?id=48065

Here's a stand alone demo of the problem this patch is fixing.

<?php

// Just a simple SQL statement for testing.
function stmt() {
    return "select 1";
}

// Create a stored procedure around our testing statement.
function setup_database() {
    $mysqli = connection();

    $sql = stmt();
    $mysqli->query("DROP PROCEDURE IF EXISTS test_bug");
    $mysqli->query("
CREATE PROCEDURE test_bug()
BEGIN
    $sql;
END
");
    print $mysqli->error;
}

// Get a database connection.
// Assumes a running MySQL 5 server on localhost with
// a test account and database (no password) which can
// drop and create procedures.
function connection() {
    return new mysqli("localhost", "test", "", "test");
}

// Using query() to call two stored procedures using query()
// will fail with "Commands out of sync"
function test_double_query($query) {
    $mysqli = connection();

    if( !$mysqli->query($query) )
        printf("First query FAILED: %s\n", $mysqli->error);

    if( !$mysqli->query($query) )
        printf("Second query FAILED: %s\n", $mysqli->error);

    printf("ok - $query\n\n");
}


setup_database();

// querying using statements or a procedure which contains
// the same statement should work the same.  It doesn't.
test_double_query("call test_bug");
test_double_query(stmt());

?>



-- 
The interface should be as clean as newly fallen snow and its behavior
as explicit as Japanese eel porn.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic