PDO连接mysql和pgsql数据库

@date:2014-09-12 23:25:00

 

PDO连接mysql数据库

 

<?php
$dsn="mysql:host=localhsot;dbname=lamp87";
$user="root";
$passwd="123";
$m = new PDO($dsn,$user,$passwd);
$stmt = $m->query("select * from stu");
$rows = $stmt->fetchAll();
var_dump($rows);
?>

 

 

 

PDO连接pgsql数据库

 

<?php
$dsn="pgsql:host=localhost;port=5432;dbname=lamp87;user=postgres;password=123456";
$m = new PDO($dsn);
$stmt = $m->query("select * from stu");
$rows = $stmt->fetchAll();
var_dump($rows);
?>

 

Build by Loppo 0.6.14