0

Hey guys, I'm having truble figuring this out: how do I initiate a zend_Db_Select object with the resources from my application.ini?

$db = Zend_Registry::get('db'); $select = $db->select();

But it's not working, I guess I have to add db to the registry first or something? Not sure how to do that though. Any ideas? I have my database details in application.ini

  • Sorry, should've mentioned that, I'm getting `No entry is registered for key 'db'` I guess I should configure 'db' in m bootstrap somewhere, but I don't know exactly how. –  Jan 20 '11 at 23:59
  • If you only want to get $db you can use: $db = Zend_Db_Table::getDefaultAdapter(); – Marcin Jan 21 '11 at 06:04

1 Answers1

0

You can only get objects from the registry which have been set before. So

$db = Zend_Registry::get('db'); $select = $db->select();

will return null, not an db adapter. You can initialize the adapter via the bootstrap. Read:

http://framework.zend.com/manual/en/zend.application.theory-of-operation.html hxxp://www.zendframework.com/manual/en/zend.application.available-resources.html

For the initialization of the db adapter (which is done by the bootstrap resource plugin for you) read:

hxxp://framework.zend.com/manual/en/zend.db.adapter.html

I wouldn't recommend using the registry at all, it is better to get the resources from the bootstrap.

Marko
  • 514
  • 1
  • 4
  • 16