php调用ms sql存储过程
2007-11-11 15:13:33 来源:WEB开发网
<?php
$hostname = "tszzp";
$dbuser = "sa";
$dbpasswd = "";
$id = mssql(WINDOWS平台上强大的数据库平台)_connect($hostname,$dbuser,$dbpasswd) or die("无法连接数据库服务器!");
//printf("%d<BR>\n", $id);
$db = mssql(WINDOWS平台上强大的数据库平台)_select_db("stock",$id) or die("无法连接stock数据库!");
$stockcode='600600';
$id = 0;
$msg = 0;
//printf("%d<BR>\n", $db);
//$query = "exec sp_test @code='600028',@id=0,@msg='000000'";
$query = "declare @result int, @id int, @msg varchar(20)\n";
$query.="exec @result=sp_test\n";
$query.="\"$stockcode\",\n";
$query.="@id output,\n";
$query.="@msg output;\n";
$query.="select @result result, @id id, @msg msg";
/*$query = "declare @result int, @id int, @msg varchar(20)\n";
$query.="exec @result=sp_test\n";
$query.="\"$stockcode\",\n";
$query.="@id output,\n";
$query.="@msg output;\n";
$query.="select @result result, @id id, @msg msg";
*///$query = "update test set stockname='2test' where stockcode='600028'";
//$query = "insert into test(stockcode,stockname,id) values ('600028','test',13)";
//$query = "select * from test where stockcode='600028'";
//$query = "select 0 where 1=0 ";
$rresult = mssql(WINDOWS平台上强大的数据库平台)_query($query) or die("无法执行SQL:$query");
$arr = mssql(WINDOWS平台上强大的数据库平台)_fetch_array($rresult);
print $result;
print "<br>\n";
printf("%d, %d, %s<br>\n", $arr[result], $arr[id], $arr[msg]);
printf("%d, %s<br>\n", $id, $msg);
//$stock = mssql(WINDOWS平台上强大的数据库平台)_fetch_array($result);
//$name = $stock[id];
//print $name;
//print "abc";
?>
赞助商链接