当我使用PDO连接到MySQL数据库,我需要连接的方法是:为什么PHP PDO DSN是MySQL与PostgreSQL的不同格式?
$pdoConnection = new PDO("mysql:host=hostname;dbname=databasename",user,password);
但是,对PostgreSQL中,DSN是更标准(IMO):
$pdoConnection = new PDO("pgsql:host=hostname;dbname=databasename;user=username;password=thepassword");
有MySQL为什么不能使用单个字符串的任何原因?或者仅仅是因为我使用的版本(PHP 5.2,MySQL 5.0,PostgreSQL 8.1)?
你不能与Wez的答案争论......这怎么还没被接受呢? :) – TML 2009-09-16 21:20:25