php连接sql server数据库并查询,感兴趣的小伙伴,下面一起跟随脚本之家 jb51.cc的小编来看看吧。 经测试代码如下:
/**
* 连接并查询sql server数据库
*
* @param
* @arrange (512.笔记) jb51.cc
**/
// Connect to the database (host,username,password)
$con = mssql_connect('localhost','admin','foo')
or die('Could not connect to the server!');
// Select a database:
mssql_select_db('Northwind')
or die('Could not select a database.');
// Example query: (TOP 10 equal LIMIT 0,10 in MySQL)
$SQL = "SELECT TOP 10 * FROM ExampleTable ORDER BY ID ASC";
// Execute query:
$result = mssql_query($SQL)
or die('A error occured: ' . mysql_error());
// Get result count:
$Count = mssql_num_rows($result);
print "Showing $count rows:<hr/>nn";
// Fetch rows:
while ($Row = mssql_fetch_assoc($result)) {
print $Row['Fieldname'] . "n";
}
mssql_close($con);
/*** 来自脚本之家 jb51.cc(jb51.cc) ***/ (编辑:安卓应用网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|