|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-04-11 09:40 UTC] dhrubab at gmail dot com
Description:
------------
I'm using PHP 5.1.2&5.1.3-RC2, MySQL 5.0.19 and PECL-PDO-MYSQL-1.0.1. All packages are latest.
MY CONFIGURE LINE:
'./configure' '--prefix=/usr/lib/php5' '--sysconfdir=/etc' '--cache-file=./config.cache' '--disable-cli' '--with-apxs2=/usr/sbin/apxs2' '--with-config-file-path=/etc/php/apache2-php5' '--with-config-file-scan-dir=/etc/php/apache2-php5/ext-active' '--without-pear' '--disable-bcmath' '--with-bz2=shared' '--enable-calendar=shared' '--with-curl=shared' '--with-curlwrappers=shared' '--disable-dbase' '--enable-exif=shared' '--without-fbsql' '--without-fdftk' '--disable-filepro' '--enable-ftp=shared' '--with-gettext=shared' '--without-gmp' '--disable-hash' '--without-hwapi' '--without-iconv' '--without-informix' '--disable-ipv6' '--without-kerberos' '--enable-mbstring=shared' '--with-mcrypt=shared' '--disable-memory-limit' '--without-mhash' '--without-ming' '--without-msql' '--without-mssql' '--with-ncurses=shared' '--with-openssl' '--with-openssl-dir=/usr' '--enable-pcntl=shared' '--disable-pdo' '--without-pgsql' '--with-pspell=shared' '--without-recode' '--disable-shmop' '--without-snmp' '--enable-soap=shared' '--enable-sockets=shared' '--without-sybase' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--with-tidy=shared' '--enable-wddx=shared' '--with-xmlrpc=shared' '--with-xsl=shared' '--with-zlib=shared' '--disable-debug' '--without-cdb' '--without-db4' '--without-flatfile' '--without-gdbm' '--without-inifile' '--without-qdbm' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--disable-gd-jis-conv' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--without-xpm-dir' '--with-gd' '--with-imap=shared' '--with-imap-ssl' '--with-mysql=shared,/usr/lib/mysql' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-mysqli=shared,/usr/bin/mysql_config' '--with-readline' '--without-libedit' '--without-mm' '--enable-sqlite-utf8'
Reproduce code:
---------------
SQL CODE:
DELIMITER $
DROP PROCEDURE IF EXISTS `dummy` $
CREATE PROCEDURE `dummy`()
BEGIN
SET @components = 'SHOW VARIABLES';
PREPARE query FROM @components;
EXECUTE query;
END $
DELIMITER ;
PHP+PDO CODE:
$dbh = new PDO('mysql:host=localhost;dbname=blah', 'blah', 'blah');
$stm = $dbh->prepare('CALL dummy()');
$stm->execute();
var_dump($stm->fetchAll());
END RESULT:
Returns several pages of garbled text that is not readable. I am not sure of the cause. This only happens when using a prepare inside a stored procedure. It also happens both on web and cli. If you need anything else please let me know.
Expected result:
----------------
EXPECTED RESULT:
I expected to see exactly the same data as when you do SHOW VARIABLES on the mysql command line. The stored procedure works on mysql command line and mysql query browser so I've narrowed it down to PDO.
Actual result:
--------------
The actual result is just garbled text that looks like it is in the wrong charset or collation but I've no idea what is causing it.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 16:00:01 2025 UTC |
This appears to be another situation where mysql gives back bogus values for the column lengths when using native prepared statements. The suggested workaround using the current snapshot is to turn on the PDO prepared statement emulator: $db = new PDO('mysql:dbname=test', 'root', ''); $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $stm = $db->prepare('CALL dummy()'); $stm->execute(); var_dump($stm->fetchAll());This script reproduces the problem using mysqli: $db = new mysqli("localhost", "root", "", "test"); $stmt = $db->stmt_init(); if ($stmt->prepare("CALL dummy()")) { $stmt->execute(); $stmt->bind_result($name, $value); while ($stmt->fetch()) { echo $name, " ", $value, "\n"; } } This is a mysql client library bug.