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

8 messages Options
Embed this post
Permalink
allergic

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

Reply Threaded More More options
Print post
Permalink
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
Duo Zheng

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

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
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

allergic

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

Reply Threaded More More options
Print post
Permalink
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 <[hidden email]> 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


Duo Zheng

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

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
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

I made the changes at pastebin, but I copied the relevant part below again for you here:

Inside _initRegDatabase

$this->bootstrap('RegConfig'); $config = Zend_Registry::get('config'); Zend_Debug::dump($config->db); exit;

Try this and you should see some kind of output. Let me know if that helps.

On Oct 4, 2009, at 3:10 PM, W Itch wrote:

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 <[hidden email]> 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



Mert Oztekin

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by allergic
Some javascript/style in this post has been disabled (why?)
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 [[hidden email]]
Sent: Sunday, October 04, 2009 10:11 PM
To: Duo Zheng
Cc: [hidden email]
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 <[hidden email]> 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.
allergic

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

Reply Threaded More More options
Print post
Permalink
Hi Duo your pastebin edits didn't seem to have been updated.  Next time try and create a new pastebin link instead. 
Fortunately you wrote the relevant code in the email so I was still able to follow your lead.

Hi Mert thanks for the alternate approach.

____________________________________________________

Bootstrap - Mert approach
http://pastebin.com/m7bc4feb1

- "print_r ..." gives me a white blank screen. 
- While "echo print_r ..." returns the number 1.



Bootstrap - Duo approach
http://pastebin.com/m6b634ceb

- The browser only returns "NULL" on the screen.  Are both of these results a bad or a good sign?
____________________________________________________


The Akrabat tutorial I've been following uses this ErrorController maybe I have to force the var_dumps in there?
In case your approaches didn't solve the problem already.

ErrorController.php
http://pastebin.com/m290cbf84



/apprentice
Duo Zheng

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

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Actually your config file for the db is

resources.db.adapter = "PDO_MYSQL" resources.db.params.host = "localhost" resources.db.params.username = "zfia" resources.db.params.password = "zfia" resources.db.params.dbname = "batman" resources.db.params.profiler = "true"

This is probably why $config->db is null as your config is setup for the "Db Resource Adapter." Take a look at: http://framework.zend.com/manual/en/zend.application.available-resources.html#zend.application.available-resources.db

For a quick start you can try this:

protected function _initRegDatabase() {
$resource = $bootstrap->getPluginResource('db'); $db = $resource->getDbAdapter();
var_dump($db); exit;
Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
}

You should get a massive output from var_dump($db); if it is working. If it is you can remove the var_dump line, but again read the reference manual linked above to understand "why".

Regards,
Duo

On Oct 5, 2009, at 11:37 AM, W Itch wrote:

Hi Duo your pastebin edits didn't seem to have been updated.  Next time try and create a new pastebin link instead. 
Fortunately you wrote the relevant code in the email so I was still able to follow your lead.

Hi Mert thanks for the alternate approach.

____________________________________________________

Bootstrap - Mert approach
http://pastebin.com/m7bc4feb1

- "print_r ..." gives me a white blank screen. 
- While "echo print_r ..." returns the number 1.



Bootstrap - Duo approach
http://pastebin.com/m6b634ceb

- The browser only returns "NULL" on the screen.  Are both of these results a bad or a good sign?
____________________________________________________


The Akrabat tutorial I've been following uses this ErrorController maybe I have to force the var_dumps in there?
In case your approaches didn't solve the problem already.

ErrorController.php
http://pastebin.com/m290cbf84



/apprentice

allergic

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

Reply Threaded More More options
Print post
Permalink
Thanks Duo for the pointers I finally managed to make some sense out of that Zend manual :-P
Reading that manual is like 99% theoretical mumbo jumbo and 1% practical examples.


Solution

Bootstrap
http://pastebin.com/m63044980

  1.         protected function _initRegDatabase()
  2.         {
  3. //_________
  4. //
  5. //   DUO
  6. //_________
  7.  
  8. /*
  9. $resource = $bootstrap->getPluginResource('db');
  10. $db = $resource->getDbAdapter();
  11. var_dump($db); exit;
  12. */
  13.  
  14. $this->bootstrap('db');
  15. $resourceDb = $this->getResource('db');
  16. //var_dump($resourceDb); exit;
  17.  
  18. Zend_Db_Table_Abstract::setDefaultAdapter($resourceDb);
  19. Zend_Registry::set('db', $resourceDb);
  20.  
  21.         }

/apprentice