Home > php教程 > php手册 > php pdo连接mssql server数据库

php pdo连接mssql server数据库

WBOY
Release: 2016-05-26 15:22:13
Original
1325 people have browsed it

本文章简单的利用了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);
Copy after login


本文地址:

转载随意,但请附上文章地址:-)

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template