让我们检查一下这段代码:
$p = new PDO('dblib:host=HOST;dbname=DBNAME',USER,PASS);
$sql = "
declare @tutu int = 100;
select @tutu [tutu];
";
$stmt = $p->prepare($sql);
$stmt->execute();
var_dump($stmt->fetch(PDO::FETCH_ASSOC));
返回:
布尔(假)
答案 0 :(得分:4)
使用nextRowset();
$p = new PDO('dblib:host=HOST;dbname=DBNAME',USER,PASS);
$sql = "
declare @tutu int = 100;
select @tutu [tutu];
";
$stmt = $p->prepare($sql);
$stmt->execute();
$stmt->nextRowset();
var_dump($stmt->fetch(PDO::FETCH_ASSOC));
返回:
array(1) {
[0]=>
array(1) {
["tutu"]=>
string(3) "100"
}
}