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

PHP MSSQL 存储过程的方法

程序员文章站 2022-12-26 15:35:08
复制代码 代码如下:function generatedoccode() { $wf_id = self::workflow_id; $doc_code = ""; $li...
复制代码 代码如下:

function generatedoccode() {
$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) or die("can't connect sql server");
mssql_select_db($this->cfg->db->params->dbname, $link) or die("select database failure");
$stmt = mssql_init("generatedoccode", $link) or die("initialize stored procedure failure");
mssql_bind($stmt, "@wf_id", $wf_id, sqlint4);
mssql_bind($stmt, "@doc_code", $doc_code, sqlvarchar, true);
mssql_execute($stmt, false);
//print "doc code is: ".$doc_code;
return $doc_code;
}

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