Welcome Guest, Not a member yet? Register   Sign In
DSN issue
#6

[eluser]Mirage[/eluser]
Not sure what you're saying - but you can get a reference to a database anywhere, including a model:

Code:
class SomeModel extends Model {

    var $edb;

    function SomeModel () {
        parent::Model();
        
        $CI=&get;_instance();

        $edbconf = array(
            'username' => $row->username,
            'password' => $row->password,
            'hostname' => $row->hostname,
            'port' => $row->port,
            'driver' => $row->driver,
            'database' => $row->database
        );

       $this->edb=$CI->load->database($edbconf,true);
    }


    function someOtherFunction() {
        $q=$this->edb->get('metas');
        // ...
        // ...
    }

}

Hope this clears it up.

Cheers!


Messages In This Thread
DSN issue - by El Forum - 05-20-2008, 08:06 AM
DSN issue - by El Forum - 05-20-2008, 10:11 AM
DSN issue - by El Forum - 05-20-2008, 10:21 AM
DSN issue - by El Forum - 05-20-2008, 10:36 AM
DSN issue - by El Forum - 05-20-2008, 10:49 AM
DSN issue - by El Forum - 05-20-2008, 12:11 PM
DSN issue - by El Forum - 05-20-2008, 01:42 PM
DSN issue - by El Forum - 05-21-2008, 03:10 AM
DSN issue - by El Forum - 05-21-2008, 08:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB