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.