2015-11-13 144 views
0

我執行使用SQLSRV存儲過程中的PHP代碼是這樣的:執行存儲過程SQLSRV在PHP

$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)); 
    } 

存儲過程是成功的DB執行和做的事情必須做,但在我的PHP代碼,我總是落在failiure如果(stmt3 ===假)收到以下錯誤:

 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)) 

這裏有什麼問題?爲什麼它執行得很好,但驅動程序處理我這個錯誤?

+0

sproc返回什麼?也許那個回報價值就是欺騙某個層面,認爲這是失敗。 –

回答

1

完成。這不是一個錯誤,只是一個警告。 然而,SQLSRV會將警告視爲錯誤,除非有另行告知:

sqlsrv_configure("WarningsReturnAsErrors", 0); 

還是要謝謝你。