我正在使用sqlsrv_prepare()运行存储过程,而直接在数据库上运行相同的存储过程时,我看到有返回的行。但是使用sqlsrv_prepare()运行并检查没有通过sqlsrv_num_rows()返回的行,我得到-1返回。
function getSOLAIndexCheckReleaseStatusCount() {
global $dbConnection, $SOLAIndexCheckReleaseStatus;
$dbConnection= dbConnectSolaReplicaDBServer();
$query = "exec [SolaQC].[dbo].[sp_BinaryQC_IndexCheckReleaseStatus]";
$params = array();
$options = array( "Scrollable" => 'buffered',"QueryTimeout" => 480);
$result = sqlsrv_prepare( $dbConnection, $query,$params,$options);
if( $result === false ) {
//die( print_r( sqlsrv_errors(), true));
die("Something didn't go too smoothly! Try refreshing?");
}
$output = "";
if (!sqlsrv_execute($result)) {
//echo "Your code is fail!";
die(print_r( sqlsrv_errors(), true));
}
if ($result) {
$check_empty = sqlsrv_has_rows($result);
if ($check_empty == true) {
$output.= sqlsrv_num_rows($result);
}
else {
$output.= sqlsrv_num_rows($result);
}
}
return $output;
}
以下是预期结果:
我不确定sqlsrv_num_rows()为什么不在PHP中返回结果。有人可以指出我正确的方向吗?
仅供参考-我正在使用Apache / 2.4.37(Win32)OpenSSL / 1.1.1a PHP / 7.3.0