Home > Backend Development > PHP Tutorial > zendframework的DB联接使用

zendframework的DB联接使用

WBOY
Release: 2016-06-13 10:37:50
Original
748 people have browsed it

zendframework的DB连接使用
现在我想实现的是,初次登陆时,就进行DB连接,然后以后再读取数据库的时候就不用再连接了,Zend_Registry是怎么使用的。
求救!!!!谢谢

------解决方案--------------------
查查zend framework手册
参考资料
http://blog.csdn.net/cfchengfei002/article/details/7354153
------解决方案--------------------

PHP code
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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template