Access Database Class |
[eluser]ranjudsokomora[/eluser]
Hello CI Coders, I am trying to initialize the database class inside of my rewrite of the router class. Is there a way to do this? Here is my code so far but I don't know how to take it from here, because this produces an error. Code: $CI = & load_class('Loader');
[eluser]Alex-Tunbridge[/eluser]
What are you using? Library, Model, Helper, Controller?
[eluser]ranjudsokomora[/eluser]
Hello Alex-Tunbridge, I am actually rewriting the router class. To accomplish this I have created a file in ./system/application/libraries. I have named the file MY_router.php At this point all I want to rewrite is the _set_routing function. I want to use the CI DB because of it's support for multiple SQL server types. Here is my code so var Code: class MY_Router extends CI_Router I want to completely rewrite how the routes are built.
[eluser]Alex-Tunbridge[/eluser]
I believe this is how its done actually. Code: class MY_Router extends CI_Router
[eluser]ranjudsokomora[/eluser]
Alex-Tunbridge, I get a few errors when I do that Quote:Severity: Notice Quote:Severity: Notice I know that the &get;_instance function isn't initialized until after the config,uri,router,output,input and language classes are loaded... there for I believe (but may be wrong) that any reference to the function &get;_instance would fail
[eluser]WanWizard[/eluser]
Correct, and it's one of the reasons it's very difficult (I wouldn't like to use the word impossible) to have database driven routing via CI's database library. People that do this usually resort to using PHP's native database functions, giving up portability. I decided to go the other way, I have a fixed route that routes all URI's to the same controller. That controller has full database access, processes the URI and loads the controller linked to that URI.
[eluser]ranjudsokomora[/eluser]
Got IT! Database driven routes, with cache! http://ellislab.com/forums/viewthread/156342/ |
Welcome Guest, Not a member yet? Register Sign In |