开发者

How to PASS your own mysql connection to Zend_DB?

I have my own mysql_connect ...etc until i wanted to use ZEND framework in particular with Zend_DB .How do I pass my connection to be used as an adapter to ZEND?

$myconn = mysql_connect('...blab',blah etc..开发者_开发问答.)
eg. Zend_DB_table::setAdapter($myconn);


Don't connect to DB on your own, rather use the factory

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

This way you can connect to DB, but it will connect only once you need the connection and thus optimize for performance...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜