Home  >  Article  >  Backend Development  >  PHP calls MS SQL stored procedure

PHP calls MS SQL stored procedure

WBOY
WBOYOriginal
2016-07-29 09:14:031160browse

在PHP中调用MS SQL存储过程

  1. functiongenerateDocCode(){
  2. $wf_id=self::WORKFLOW_ID;
  3. $doc_code="";
  4. $link=mssql_connect($this->cfg->db->params->host,$this->cfg->db->params->username,$this->cfg->db->params->password)ordie("Can'tconnectsqlserver");
  5. mssql_select_db($this->cfg->db->params->dbname,$link)ordie("Selectdatabasefailure");
  6. $stmt=mssql_init("GenerateDocCode",$link)ordie("initializestoredprocedurefailure");
  7. mssql_bind($stmt,"@wf_id",$wf_id,SQLINT4);
  8. mssql_bind($stmt,"@doc_code",$doc_code,SQLVARCHAR,true);
  9. mssql_execute($stmt,false);
  10. //print"DocCodeis:".$doc_code;
  11. return$doc_code;
  12. }

先调用mssql_init语句用于初始化存储过程,而后调用mssql_bind语句指定存储过程参数,最后调用mssql_execute执行存储过程

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了PHP调用MS SQL 存储过程,包括了存储过程,sqlserver方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

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