Welcome Guest, Not a member yet? Register   Sign In
Extending DB driver
#1

[eluser]cemaleker[/eluser]
Is there any way to extend core DB driver?

I just found there's a problem with limit on mssql active records driver. I am trying to extend CI_DB_mssql_driver to fix the issue. But my class doesn't load automatically as a core class. It's probably because of the code at DB.php line 132.

Code:
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';

I think that line should first check any core extension classes and load it if exists.

Code:
if(class_exists($config['subclass_prefix'].'DB_'.$params['dbdriver'].'_driver')) {
            $driver = $config['subclass_prefix'].'DB_'.$params['dbdriver'].'_driver'
        }
        else {
            $driver = 'CI_DB_'.$params['dbdriver'].'_driver';
        }

Well I found a solution but I can't change CI library because we use a centralized library. Is there a way to load my core class inside application directory?
#2

[eluser]Colin Williams[/eluser]
include()
#3

[eluser]cemaleker[/eluser]
[quote author="Colin Williams" date="1261188488"]include()[/quote]

Actually the main problem is, I can't reach my extending class with $this->db. My class is located in library directory and CI includes it very well, class_exists('MY_DB_mssql_driver') returns true. Maybe I could use
Code:
$this->db = get_instance('MY_DB_mssql_driver')
in controller construct but adding this to all controllers doesn't looks like the best solution.

Also I think the CI code must be fixed for next release.
#4

[eluser]jedd[/eluser]
You may get some satisfaction from the answer to the 'can I extend the DB class?' question in the [url="/wiki/FAQ"]FAQ[/url].

Assuming you haven't read the FAQ already . . .
#5

[eluser]cemaleker[/eluser]
[quote author="jedd" date="1261277446"]You may get some satisfaction from the answer to the 'can I extend the DB class?' question in the [url="/wiki/FAQ"]FAQ[/url].

Assuming you haven't read the FAQ already . . .[/quote]

That's exactly what I'm looking for. I'll get a closer look to it as soon as I can. Thanks...
#6

[eluser]jedd[/eluser]
[quote author="cemaleker" date="1261278164"]
That's exactly what I'm looking for. I'll get a closer look to it as soon as I can. Thanks...[/quote]

Yeah - it's almost like we anticipated people might ask this question. ;|




Theme © iAndrew 2016 - Forum software by © MyBB