|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-08-29 17:55 UTC] grzegorz at heex dot pl
Description:
------------
If PDO_MSSQL PDOStatement is called 2 times and the first returned no result than second one return strange result.
PDO_MYSQL works fine.
Tested on Apache and IIS
Reproduce code:
---------------
$pdo = new PDO("mssql:host=[host];dbname=[base]",[user],[pass]);
$sth = $pdo->prepare("SELECT id FROM sometable WHERE id=:parentId");
$sth->execute(array(':parentId'=>1));
//or
//$sth->bindValue(':parentId',1,PDO::PARAM_INT);
$res1 = $sth->fetchAll();
$sth->closeCursor();
$sth->execute(array(':parentId'=>2));
//or
//$sth->bindValue(':parentId',2,PDO::PARAM_INT);
$res2 = $sth->fetchAll();
$sth->closeCursor();
Expected result:
----------------
$res1 = array[0] //empty
$res2 = array[
0 = array['value' => 3]
1 = array['value' => 6]
]
Actual result:
--------------
$res1 = array[0] //empty
$res2 = array[
0 = array['[]' => null]
1 = array['[]' => null]
]
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 14:00:02 2025 UTC |
Statetment should be: $sth = $pdo->prepare("SELECT value FROM sometable WHERE id=:parentId");Tried to reproduce with code in trunk, returns expected results. $db->query("create table test (id int not null primary key)"); $db->query("insert into test(id) values(2)"); $sth = $db->prepare("SELECT id FROM test WHERE id=:parentId"); $sth->execute(array(':parentId'=>1)); $res1 = $sth->fetchAll(); var_dump($res1); $sth->execute(array(':parentId'=>2)); $res2 = $sth->fetchAll(); var_dump($res2); array(0) { } array(1) { [0]=> array(2) { ["id"]=> string(1) "2" [0]=> string(1) "2" } }