PDO prepared statements sometimes returns empty resultset
am 23.04.2007 18:51:30 von Emil IvanovHi,
I'm trying to get some data form a MySQL db using PDO and prepared
statement, but I noticed that sometimes it fetches an empty result set,
but sometimes does what it's supposed to do - returns the whole result set.
The environment is WinXP SP2 Home, Apache 2.2.4, PHP 5.2.1 and MySQL 5.0.27.
Here is some code:
$db = new PDO(
'mysql:host=localhost;dbname=name_of_db',
'user_name',
'password',
array (
PDO::ATTR_PERSISTENT => true
)
);
$db->query('SET CHARACTER SET utf8');
$stmt = $db->prepare("CALL sp_get_all_currencies(:lang_id)");
$stmt->bindValue(':lang_id', $currenctLanguageId, PDO::PARAM_INT);
$stmt->execute();
$currencies = $stmt->fetchAll();
So here, $currencies sometimes is an empty array, and after a refresh of
the browser it populates.
I also noticed that it works ok with $db->query(), but query doesn't
have that fancy param binding (I think).
Is there some caching or something... Is this a bug in PHP or I'm not
getting the picture right?
Regards,
Emil Ivanov
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php