来源:http://trac.seagullproject.org/wiki/Howto/DB/MultipleDbs

如何在多个数据库源上工作

默认情况下,使用如下代码来获得Seagull数据库的db句柄的标准方式

$dbh = & SGL_DB::singleton();

上面代码是假设你在配置文件中正确配置了一个数据库。如果你想连接到一个额外的数据库,使用同样的方法,并给它传递一个$dsn参数,如:

$dsn = 'pgsql://username:password@localhost/myDB';
$dbhExt = & SGL_DB::singleton($dsn);

这样你就可以像普通的PEAR::DB或SGL_DB扩展版本一样使用$dbhEx来连接到你的数据库。

关于PEAR 数据源命名规则的更多资料请看这里

 
howto/db/multipledbs.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2