zendframework的DB连接使用
现在我想实现的是,初次登陆时,就进行DB连接,然后以后再读取数据库的时候就不用再连接了,Zend_Registry是怎么使用的。
求救!!!!谢谢
------解决方案--------------------
查查zend framework手册
参考资料
http://blog.csdn.net/cfchengfei002/article/details/7354153
------解决方案--------------------
PHP code1 2 3 4 5 6 | config.ini[general]db.adapter=PDO_MYSQLdb.config.host=localhostdb.config.username=rootdb.config.password=123456db.config.dbname=test $config = new Zend_Config_Ini( './application/config/config.ini' ,null, true);Zend_Registry::set( 'config' , $config ); $db =Zend_Db::factory( $config ->general->db->adapter, $config ->general->db->config->toArray()); $db ->query( 'SET NAMES UTF8' );Zend_Db_Table::setDefaultAdapter( $db );Zend_Registry::set( 'db' , $db );<br><font color= "#e78608" >------解决方案--------------------</font><br>你想用Zend_Registry实现这个是不行的。因为这个只在一次请求内有效,你要实现登录 保存数据之类的 老实用session吧<div class = "clear" >
</div>
|
Nach dem Login kopieren