Zendcasts Forum

A community of developers who work with the Zend Framework and other enterprise PHP technologies

You are not logged in.

#1 2010-04-19 15:12:01

shaded2
New member
Registered: 2010-02-16
Posts: 9

accessing db options from application.ini

This is probably simple, but searching the web there are such a wide variety of partial answers. Everyone seems to be doing it differently and no one posts the complete solutions.

so far i've been working off the zend_db videos and i have a service class with options array like this.

        $options = array(
            'host'          => 'localhost',
            'username'      => 'root',
            'password'      => 'password',
            'dbname'        => 'mydb'
        );
        
        
    
        $this->db = Zend_Db::factory('PDO_MYSQL', $options);
        Zend_Db_Table_Abstract::setDefaultAdapter($this->db);

Works fine, now i have multiple services and models and dont want to keep repeating this, so in application.ini i have

resources.db.adapter = "PDO_MYSQL"
resources.db.isdefaulttableadapter = true
resources.db.params.dbname = "mydb"
resources.db.params.username = "root"
resources.db.params.password = "password"
resources.db.params.host = "localhost"
resources.db.params.charset = "UTF8" 

so how do i get this to work in my service class and models?

Offline

Board footer

Powered by FluxBB