2009年10月5日星期一

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

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

没有评论: