2009年10月4日星期日

RE: [fw-db] Fatal error: Uncaught exception 'Zend_Db_Exception' with message 'Adapter name must be specified in a string'

protected function _initRegDatabase()
    {
    $config = Zend_Registry::get('config');
        print_r($config->db);exit();   // Add this line and post us what you read on browser?

        $db = Zend_Db::factory($config->db);                            //   This line seems to cause the Error!
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        Zend_Registry::set('db', $db);
    }
 
 
From: W Itch [mailto:im.allergic.2.mailing.lists@gmail.com]
Sent: Sunday, October 04, 2009 10:11 PM
To: Duo Zheng
Cc: fw-db@lists.zend.com
Subject: Re: [fw-db] Fatal error: Uncaught exception 'Zend_Db_Exception' with message 'Adapter name must be specified in a string'
 
1.) Howto var dump?
Hi Duo could you teach me how to do the var dump thing correctly?  I'm a PHP newbie, every view page gives me that Fatal error message.  I don't know how to force a var dump into an Error view page.  I tried to put the "Zend_Debug::dump();" into Bootstrap but nothing new happens.

View page - Fatal error
http://pastebin.com/m63b8f8d

Bootstrap - Zend_Debug::dump()
http://pastebin.com/m3e88b3f6

___________________________________________________________________________


2.) The story
My web application is 99% based on Akrabats tutorial in case this information helps.
http://akrabat.com/zend-framework-tutorial/

The Akrabat Bootstrap file looks like this.  And _initAutoload() function usually starts up the config.ini file and database connection.
http://pastebin.com/m3e88b3f6

application/configs/application.ini
http://pastebin.com/m4c2fd8a3


So my _initRegDatabase() function seems redundant.  Do you think that I need to set the config and database into registry by working within _initAutoload() function instead?  By using the Zend_Application_Module_Autoloader somehow some way?


/apprentice









On Sun, Oct 4, 2009 at 7:57 PM, Duo Zheng <duozheng@gmail.com> wrote:
apprentice,
What is the var dump output on $config->db? Check the format of it against the proper format listed in the reference manual(http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.connecting.factory-config). 
 
Regards,
Duo
 
On Oct 4, 2009, at 6:16 AM, W Itch wrote:

Fatal error: Uncaught exception 'Zend_Db_Exception' with message 'Adapter name must be specified in a string'

I've been googling this problem but can't find any hints to follow.  Can somebody help me fix this Error?
The code that is causing this error is this:


Bootstrap
    protected function _initRegDatabase()
    {
    $config = Zend_Registry::get('config');
       
        $db = Zend_Db::factory($config->db);                            //   This line seems to cause the Error!
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        Zend_Registry::set('db', $db);
    }


/apprentice
 
 

  ________________________________  
Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system.

没有评论: