Re: [PATCH] mysqli #35203 / #48065 Eliminate special case for calling procedures in mysqli
| From: | Andrey Hristov | Date: | Sun, 26 Apr 2009 07:17:30 +0000 |
| Subject: | Re: [PATCH] mysqli #35203 / #48065 Eliminate special case for calling procedures in mysqli | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-43774@lists.php.net to get a copy of this message | ||
Hi,
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).
Best,
Andrey
Michael G Schwern wrote:
This is a patch against 5.2.9 to fix mysqli::query so a user can call stored procedures the same as they do any other statement. No more multi_query() and next_result() work arounds necessary to avoid a "Commands out of sync" error. I note this has been rejected several times in the tracker as not being a bug. I feel its a clear encapsulation violation making the user special case a query just because it's calling a stored procedure. Aside from just being very inconvenient, some API wrappers around mysqli, Drupal 6 for example, leave the user with no way to get at mysqli::multi_query(). Anyhow, here's a complete patch with a test. The technique and code is lifted from Perl's DBD::mysql driver, which you can see here as mysql_st_free_result_sets() http://cpansearch.perl.org/src/CAPTTOFU/DBD-mysql-4.011/dbdimp.c Before each query it frees any results still hanging around on the connection, which is essentially what a user has to do. I'm not really a C programmer so I left most of the code as is, do/while loop and all. I'm not sure how mysqli normally handles errors so I just went with a printf() and return trusting that you'll fix that up. It causes test 057 to fail because that test deliberately generates an out of sync error, which my code diligently prints. So that should go away with fixed error handling. Thanks, Schwern