PDO fetching garbled data from MySQL (SP with PS)

From: Date: Mon, 25 Jun 2007 19:00:59 +0000
Subject: PDO fetching garbled data from MySQL (SP with PS)
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-4749@lists.php.net to get a copy of this message
I'm getting garbled data while fetching rows from a stored procedure that has a prepared statement. The garbage looks like memory content and sometimes seems to be from old queries, even from other connections in different databases with different users. Stored procedure: ----------------- DELIMITER // DROP PROCEDURE IF EXISTS bugpdo// CREATE PROCEDURE bugpdo() BEGIN PREPARE stmt FROM "SELECT 1 AS a, 'second column' AS b, NOW() AS c FROM dual"; EXECUTE stmt; DEALLOCATE PREPARE stmt; END; // DELIMITER ; PHP Script: ----------------- <?php $dbh = new PDO( 'mysql:host=localhost;dbname=testes', 'nobody', 'nobody'); $res = $dbh->query("CALL bugpdo()"); var_dump($res->fetch()); ?> Expected result: ----------------------- mysql> CALL bugpdo(); +---+---------------+---------------------+
| a | b             | c                   |
+---+---------------+---------------------+ | 1 | second column | 2007-06-25 07:19:24 | +---+---------------+---------------------+ 1 row in set (0.00 sec) Actual result: ------------------- array(6) { ["a"]=> string(19) "2334111931572777741" [0]=> string(19) "2334111931572777741" ["b"]=> string(99) "olumn2007-06-25 07:18:34&#65533;obody&#65533;¦Žº£Ö–ü*(c)K7Še›ëÊi¨½testes&#65533;b3d4dc4b 30dcdb2468c47cca06ed1d90d3980ca" [1]=> string(99) "olumn2007-06-25 07:18:34&#65533;obody&#65533;¦Žº£Ö–ü*(c)K7Še›ëÊi¨½testes&#65533;b3d4dc4b 30dcdb2468c47cca06ed1d90d3980ca" ["c"]=> NULL [2]=> NULL } Things get even more weird when I connect through the MySQL Cli and call a stored procedure that uses a prepared statement to fetch data from a table. When I get back to PHP, the garbage above shows pieces of the resultset of that query, like this: (...) äu.$ê›?±~ftestes�nco-de-dados/mysql���Amanda Palmer (...) That "Amanda Palmer" should never be shown there, PHP/PDO doesn't know about it, and actually the procedure called on cli was in a different database with a different user. If I close the cli then I get no more these values, just the old garbage. Thus I suspect it might not be a problem in PDO itself but MySQL instead, although cli displays the right result. If so I wonder whether someone more experienced could forward it to the MySQL devs with more technical details. Versions ------------- PHP 5.2.0-10+lenny1 (cli) (built: May 26 2007 08:23:53) Mysql 5.0.38-Debian_1-log

« previous php.pecl.dev (#4749) next »