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

PHP calls MS SQL stored procedure

巴扎黑
巴扎黑Original
2016-11-10 11:00:121030browse

Calling MS SQL stored procedures in PHP

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

First call the mssql_init statement to initialize the stored procedure, then call the mssql_bind statement to specify the stored procedure parameters, and finally call mssql_execute to execute the stored procedure.


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