|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-19 09:32 UTC] tony2001@php.net
[2007-04-04 19:59 UTC] georg@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 08:00:01 2025 UTC |
Description: ------------ Using a prepared statement in a stored procedure in MySQL 5 mess up bind_result() parameters. The prepared statement can be anything, it seems. Reproduce code: --------------- - create a stored procedure in the mysql test database DELIMITER $$ DROP PROCEDURE IF EXISTS test.spTest$$ CREATE PROCEDURE test.spTest() BEGIN PREPARE statement FROM "SET @x = 123"; EXECUTE statement; DEALLOCATE PREPARE statement; SELECT 5, 8; END$$ - then call it from PHP like this <?php $mysqli = new mysqli("localhost", "user", "pwd", "test"); $statement = $mysqli->prepare("CALL spTest()"); $statement->execute(); $statement->bind_result($a, $b); $statement->fetch(); print "a = $a, b = $b"; ?> Expected result: ---------------- Expected result a = 5, b = 8 we can confirm this by doing: mysql> call spTest(); +---+---+ | 5 | 8 | +---+---+ | 5 | 8 | +---+---+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.02 sec) (moving "SELECT 5, 8" above EXECUTE in the stored procedure yield the expected result) Actual result: -------------- Actual result (in this case): a = , b = 15763698207438849 but depending on a variety of unknown factors the bound result can be complete garble as well.