欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php 扩展sqlsrv调用mssql存储过程

程序员文章站 2022-04-23 11:03:10
...
  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. //参数需要以如下数组方式赋值并标明类型,SQLSRV_PARAM_IN是输入类型,SQLSRV_PARAM_OUT是输出类型。注意要按照存储过程定义的顺序赋值
  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. }
复制代码