Return to Snippet

Revision: 34241
at October 19, 2010 20:31 by Rhoxus


Updated Code
protected function _initDb()
{
/*
Assuming your config contains the following:

database.adapter = [Adapter type], for MySQL = Pdo_Mysql
database.host     = [Host URL]
database.username = [Username]
database.password = [Password]
database.dbname = [DBName]
*/

$config = Zend_Registry::get('config');

$db = Zend_Db::factory($config->database->adapter, array(
    'host'      => $config->database->host,
    'username'  => $config->database->username,
    'password'  => $config->database->password,
    'dbname'    => $config->database->dbname
));

Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Registry::set('db', $db);

Revision: 34240
at October 19, 2010 20:27 by Rhoxus


Initial Code
protected function _initDb()
{
    $config = Zend_Registry::get('config');

    $db = Zend_Db::factory($config->database->adapter, array(
        'host'      => $config->database->host,
        'username'  => $config->database->username,
        'password'  => $config->database->password,
        'dbname'    => $config->database->dbname
    ));

   Zend_Db_Table_Abstract::setDefaultAdapter($db);
   Zend_Registry::set('db', $db);
}

Initial URL

                                

Initial Description
Goes in /Application/Bootstrap.php

Initial Title
Init Zend Framework DB

Initial Tags

                                

Initial Language
PHP