在 PHP 中使用 sqlsrv 执行存储过程
Executing Stored Procedure with sqlsrv in PHP
我正在 php 代码中使用 sqlsrv 执行存储过程,如下所示:
$tsql_callSP = "{call cnt.stproc1(?)}";
$rotCode = '1111';
$params = array(
array($rotCode, SQLSRV_PARAM_IN),
);
$serverName = "xxxxxxx\wwwwwww"; //serverName\instanceName
$connectionInfo = array( "Database"=>"aaaaaaaaaaa", "UID"=>"bbbbbbb", "PWD"=>"ccccccc");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
/* Execute the query. */
$stmt3 = sqlsrv_query( $conn, $tsql_callSP, $params);
if( $stmt3 === false )
{
echo "Error in executing statement 3.\n";
die( print_r( sqlsrv_errors(), true));
}
存储过程在数据库中成功执行并完成了它必须做的事情,但在我的 php 代码中,如果 (stmt3 === false) 收到以下错误,我总是失败:
Array ( [0] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]0510620150922777 [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]0510620150922777 ) [1] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]UPDATE 004 [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]UPDATE 004 ) )
这里有什么问题?为什么执行的很好,驱动却给我处理了这个错误?
完成。这不是错误,只是警告。
但是,sqlsrv 将警告视为错误,除非另有说明:
sqlsrv_configure("WarningsReturnAsErrors", 0);
谢谢。
我正在 php 代码中使用 sqlsrv 执行存储过程,如下所示:
$tsql_callSP = "{call cnt.stproc1(?)}";
$rotCode = '1111';
$params = array(
array($rotCode, SQLSRV_PARAM_IN),
);
$serverName = "xxxxxxx\wwwwwww"; //serverName\instanceName
$connectionInfo = array( "Database"=>"aaaaaaaaaaa", "UID"=>"bbbbbbb", "PWD"=>"ccccccc");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
/* Execute the query. */
$stmt3 = sqlsrv_query( $conn, $tsql_callSP, $params);
if( $stmt3 === false )
{
echo "Error in executing statement 3.\n";
die( print_r( sqlsrv_errors(), true));
}
存储过程在数据库中成功执行并完成了它必须做的事情,但在我的 php 代码中,如果 (stmt3 === false) 收到以下错误,我总是失败:
Array ( [0] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]0510620150922777 [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]0510620150922777 ) [1] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]UPDATE 004 [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]UPDATE 004 ) )
这里有什么问题?为什么执行的很好,驱动却给我处理了这个错误?
完成。这不是错误,只是警告。 但是,sqlsrv 将警告视为错误,除非另有说明:
sqlsrv_configure("WarningsReturnAsErrors", 0);
谢谢。