开发者

How to PASS your own mysql connection to Zend_DB?

开发者 https://www.devze.com 2022-12-19 05:04 出处:网络
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?

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

精彩评论

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

关注公众号