1

我有自己的 mysql_connect ...等,直到我想将 ZEND 框架与 Zend_DB 一起使用。如何传递我的连接以用作 ZEND 的适配器?

$myconn = mysql_connect('...blab',blah etc...)
eg. Zend_DB_table::setAdapter($myconn);
4

1 回答 1

3

不要自己连接数据库,而是使用工厂

$db = Zend_Db::factory('Pdo_Mysql', array(
    'host'     => '127.0.0.1',
    'username' => 'webuser',
    'password' => 'xxxxxxxx',
    'dbname'   => 'test'
));

这样您就可以连接到数据库,但它只会在您需要连接时连接,从而优化性能......

于 2010-02-06T11:27:07.680 回答