一聚教程网:一个值得你收藏的教程网站

热门教程

php pdo连接mssql server数据库

时间:2022-06-24 19:00:58 编辑:袖梨 来源:一聚教程网

 代码如下 复制代码

$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);

热门栏目