Welcome Guest, Not a member yet? Register   Sign In
[ci 2.0] extend/overload db driver
#1

[eluser]MVUG[/eluser]
Is it, with the new ci 2.0, possible to overload/extend a db driver, like the oci8 driver?
#2

[eluser]BrianJM[/eluser]
Quote:Drivers are a special type of Library that has a parent class and any number of potential child classes. Child classes have access to the parent class, but not their siblings. Drivers provide an elegant syntax in your controllers for libraries that benefit from or require being broken down into discrete classes.

You can extend a library, so you should be able to extend a driver. Give it a try and report your results!

Creating Core System Classes
Creating Libraries
#3

[eluser]MVUG[/eluser]
Does somebody have experience with this? I want to overload a DB driver, OCI8 driver.
#4

[eluser]13ankster[/eluser]
You can view extend DB driver in FuelCMS Sourcecode
Code:
/** Load the database drivers **/
    public function database($params = '', $return = FALSE, $active_record = NULL) {
        if (class_exists('CI_DB', FALSE) AND $return == FALSE AND $active_record == NULL)
            return;

        require_once BASEPATH.'database/DB'.EXT;
        
        $db = DB($params, $active_record);
        
        // <!-- FUEL
        $my_driver = config_item('subclass_prefix').'DB_'.$db->dbdriver.'_driver';
        $my_driver_file = APPPATH.'core/'.$my_driver.EXT;
        
        if (file_exists($my_driver_file))
        {
            require_once($my_driver_file);
            $db = new $my_driver(get_object_vars($db));
        }

        if ($return === TRUE)
        {
            return $db;
        }
        //    return DB($params, $active_record);
        // FUEL -->
        CI::$APP->db = '';
        //CI::$APP->db = DB($params, $active_record);
        CI::$APP->db = $db;
        $this->_ci_assign_to_models();
        return CI::$APP->db;
    }




Theme © iAndrew 2016 - Forum software by © MyBB