本文實例講述了利用php的pdo來連接微軟的mssql server數據庫的方法,分享給大家供大家參考。具體實現方法如下:
復制代碼 代碼如下:$dsn = 'mssql:dbname=bookStore_demo;host=192.168.1.106';
$user = 'sa';
$password = '123';
//mssql_connect('192.168.1.106','sa','123');
//echo 22;
try {
// echo 11;
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
//$sql = 'select * from article';
$sth = $dbh->query($sql);
$result = $sth->fetchAll();
var_dump($result);
希望本文所述對大家的PHP程序設計有所幫助。