Home >Backend Development >PHP Tutorial >PHP extends sqlsrv to call mssql stored procedure

PHP extends sqlsrv to call mssql stored procedure

WBOY
WBOYOriginal
2016-07-25 09:09:481421browse
  1. $serverName = "127.0.0.1";
  2. $connectionInfo = array( "UID"=>"sa","PWD"=>"","Database"=>"test");
  3. $conn = sqlsrv_connect( $serverName, $connectionInfo);
  4. if( $conn === false )
  5. {
  6. echo "Could not connect.n";
  7. die( print_r( sqlsrv_errors(), true));
  8. }
  9. $spnumber = '10655****00';
  10. $chargenumber = '155****6789';
  11. //Parameters need to be assigned in the following array format and marked with types. SQLSRV_PARAM_IN is the input type, and SQLSRV_PARAM_OUT is the output type. Note that values ​​must be assigned in the order defined by the stored procedure
  12. $params = array(
  13. array(&$spnumber, SQLSRV_PARAM_IN),
  14. array(&$chargenumber, SQLSRV_PARAM_IN)
  15. );
  16. $tsql_callSP = "{call msgexpress_UnicomNewSubmit(?,?) }";
  17. $stmt3 = sqlsrv_query( $conn, $tsql_callSP, $params);
  18. if( $stmt3 === false )
  19. {
  20. echo "Error in executing statement 3.n";
  21. die( print_r( sqlsrv_errors( ), true));
  22. }
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn