php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44897 failed to prepare statement
Submitted: 2008-05-02 20:27 UTC Modified: 2008-07-23 14:11 UTC
From: top dot bagger at bk dot ru Assigned: andrey (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.2.6 OS: CentOS 5
Private report: No CVE-ID: None
 [2008-05-02 20:27 UTC] top dot bagger at bk dot ru
Description:
------------
"prepare" method call returns false if mysql stored procedure was prepared before

Reproduce code:
---------------
$my = new mysqli("localhost","test","test","test_db");
$stmta = $my->prepare("CALL sp_auth_user(?,?)");
$user = 'user';
$pass = 'pass';
$stmta->bind_param("ss", $user,$pass);
$stmta->execute();
$stmta->bind_result($state);
$stmta->fetch();
printf("State of user: %s\n", $state);
$stmta->close();
$stmtb = $my->prepare("SELECT userId FROM appUsers WHERE login = ?");
if ($stmtb) echo "prepare succeeded";
else {
	echo "prepare failed<br />";
	echo "errno: ", $my->errno, "  - error: ", $my->error, "<br />";
}

Expected result:
----------------
$stmtb contains mysqli_stmt object

Actual result:
--------------
$stmtb is false

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-02 20:29 UTC] top dot bagger at bk dot ru
Sorry, I forgot to add my output of this:

State of user: 1prepare failed
errno: 2013 - error: Lost connection to MySQL server during query
 [2008-05-27 00:14 UTC] jani@php.net
Maybe if you fetch all the results caused by the execute of the CALL statement before you try executing another query?

e.g. while($stmta->fetch());
 [2008-05-27 07:02 UTC] top dot bagger at bk dot ru
Mysql function that I wrote returns only one result. But anyway I will try and provide you feedback.
 [2008-07-14 17:30 UTC] uw@php.net
Andrey, I can reproduce this with libmysql and mysqlnd using PHP 5.3 CVS and a recent version of MySQL 5.1. Have a look, I'll send you the test. 


 [2008-07-23 14:11 UTC] andrey@php.net
The SP call returns more than one RSet. If you use PS then libmysql can't handle more than one RSet out of an executed PS. If you use mysqlnd, available from 5.3+, then you will be able to do it. Usually you need to "eat" all result sets till the line is clear but mysqlnd will clean if you do mysqli_stmt_close()
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 22:01:33 2024 UTC