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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: top dot bagger at bk dot ru
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Wed May 01 12:01:31 2024 UTC