zendframework的DB串連使用,該如何解決

來源:互聯網
上載者:User
zendframework的DB串連使用
現在我想實現的是,初次登陸時,就進行DB串連,然後以後再讀取資料庫的時候就不用再串連了,Zend_Registry是怎麼使用的。
求救!!!!謝謝
------解決方案--------------------
查查zend framework手冊
參考資料
http://blog.csdn.net/cfchengfei002/article/details/7354153
------解決方案--------------------

config.ini
[general]
db.adapter=PDO_MYSQL
db.config.host=localhost
db.config.username=root
db.config.password=123456
db.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);



------解決方案--------------------
你想用Zend_Registry實現這個是不行的。因為這個只在一次請求內有效,你要實現登入 儲存資料之類的 老實用session吧
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.