The last parameter '$status' is suppose to return a 0 or 1. How do I get the value of that output parameter? Echoing $result always returns 1. The stored procedure works under classic asp and .NET, but I need to do it under PHP.
$conn = sqlsrv_connect($serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$tsql = "{call spName(?,?,?,?)}";
$params = array(
array(&$param1, SQLSRV_PARAM_IN),
array(&$param2, SQLSRV_PARAM_IN),
array(&$param3, SQLSRV_PARAM_IN),
array(&$status, SQLSRV_PARAM_OUT)
);
$stmt = sqlsrv_prepare($conn, $tsql, $params);
if($stmt===false ) {
if( ($errors = sqlsrv_errors() ) != null) {
die( print_r( sqlsrv_errors(), true));
}
$result = sqlsrv_execute($stmt);
if($result === false){
die( print_r( sqlsrv_errors(), true));
}
echo " " . $result;
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
令人难以置信的是,我要做的就是回显输出参数本身(在此示例中为$ status)以查看结果。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.