PDO连接mysql数据库
1 <?php 2 $dsn="mysql:host=localhsot;dbname=lamp87"; 3 $user="root"; 4 $passwd="123"; 5 $m = new PDO($dsn,$user,$passwd); 6 $stmt = $m->query("select * from stu"); 7 $rows = $stmt->fetchAll(); 8 var_dump($rows); 9 ?>
PDO连接pgsql数据库
1 <?php 2 $dsn="pgsql:host=localhost;port=5432;dbname=lamp87;user=postgres;password=123456"; 3 $m = new PDO($dsn); 4 $stmt = $m->query("select * from stu"); 5 $rows = $stmt->fetchAll(); 6 var_dump($rows); 7 ?>