PHP中使用存储过程

来源:互联网 发布:淘宝家具类目如何操作 编辑:程序博客网 时间:2024/05/16 12:20

下面是一个简单的存贮过程
CREATE PROCEDURE [sp_mystoreprocedure] AS
select  Host,User,Password from user

<?
define ("OLEDB_CONNECTION_STRING",
"Provider=SQLOLEDB; Data Source=zzb; Initial Catalog=Northwind; User ID=sa; Password=");
$dbc = new COM("ADODB.Connection");
$dbc->Open(OLEDB_CONNECTION_STRING);
$command = "sp_mystoreprocedure";
$rs = $dbc->Execute($command); // Recordset
$i = 0;

echo '<table cellSpacing="1" cellPadding="3" width="600" align="center" bgColor="#000000" border="0">
<tr vAlign="bottom" bgColor="#9999cc">
<th>Directive</th>
<th>Local Value</th>
<th>Master Value</th>
</tr>';

while (!$rs->EOF) {
$i += 1;
$fld0 = $rs->Fields(0);
$fld1 = $rs->Fields(1);
$fld2 = $rs->Fields(2);
print '<tr vAlign="baseline" bgColor="#cccccc">
<td bgColor="#ccccff"><b>';
print $fld0->value;
print '</b><br></td>
<td align="middle">';
print $fld1->value;
print '</td><td align="middle">';
print $fld2->value;
print '</td></tr>';

$rs->MoveNext();
}
print '</TABLE>';

$rs->Close();
?>

原创粉丝点击