我使用 sqlsrv 和 PHP 低于 SP HIt。片段对我不起作用。对于下面的代码,我得到“SQL SRV QUERY NOT RAN”。请提供您的建议,如何实现 php + sqlsrv + SP。
$query = "{CALL call_user_name}";
if ( ($res = sqlsrv_query( CONNSTR, $query)) )
{
do
{
if ( sqlsrv_num_fields($res) ) // one way to check if results returned.
{
while( ($row = sqlsrv_fetch_array( $res, $type)) )
{
$data[] = $row;
}
}else{echo "sqlsrv_num_fields not working";}
} while ( sqlsrv_next_result($res) ) ;
sqlsrv_free_stmt($res); // not essential, but good form if your script does lots of other stuff.
}else{
echo "SQL SRV QUERY NOT RAN ";die( print_r( sqlsrv_errors(), true));
}