1.Com鏈接,ADODB.Connection
復制代碼 代碼如下:
$conn = new Com("ADODB.Connection"); //實例化一個Connection對象
$connstr = "provider=sqloledb;datasource=.;uid=sa;pwd=123456;database=jnold;";
$conn->Open($connstr);
$rs = new Com("ADODB.Recordset"); //實例化一個Recordcount對象
$rs->Open('select * from News where bigclassid = 59 And LeadPostil is null', $conn, 1, 1);
$count = $rs->RecordCount;
echo "共有{$count}條紀錄<br />";
for($i = 0; $i < $count ; $i++){
$arr_result[$i]['Title'] = addslashes($rs->Fields('Title')->Value);//標題
$arr_result[$i]['Color'] = addslashes($rs->Fields('titlecolor')->Value?$rs->Fields('titlecolor')->Value:");//標題顏色
$arr_result[$i]['WenHao'] = addslashes($rs->Fields('OtherText')->Value);//文號
}
2.ODBC連接mssql
復制代碼 代碼如下:
$dbhost = ";
$dbuser = "; //你的mssql用戶名
$dbpass = "; //你的mssql密碼
$dbname = "; //你的mssql庫名
$connect=odbc_connect("Driver={SQL Server};Server=$dbhost;Database=$dbname","$dbuser","$dbpass");
$sql="select * from content";
$exec=odbc_exec($connect,$sql);
while($row = (odbc_fetch_array($exec)))
{
$row['id'] //?取字段值
…
}