Welcome Guest, Not a member yet? Register   Sign In
Initialize DB Connection at Router Class instead of at Controller Class
#1

[eluser]Unknown[/eluser]
I need to access a model class within the router class. I need to check the url slug in order to determine with controller to access. Is there a way to achieve this without having to open/close a db connection in the router class and opening a db connection within the controller class?
#2

[eluser]alexwenzel[/eluser]
Dont know exactly what you try to do, but my first guess is:

Look at hooks!

http://ellislab.com/codeigniter/user-gui...hooks.html
#3

[eluser]Unknown[/eluser]
That does not answer my question.
#4

[eluser]regal2157[/eluser]
I do believe alex is in the right. If a pre_system hook won't work (I haven't tested, so I am not sure if it would work) But if that does not work, you might need to hack the core. Not sure what you are looking to do, but the router gets called around line 170 in /core/Codeigniter.php

As for multiple opening and closing connections, probably not.
#5

[eluser]alexwenzel[/eluser]
In my opinion he should use the pre_controller hook.

Its perfect for redirecting to a specific controller based on database interaction.
#6

[eluser]Aken[/eluser]
Try explaining your actual situation and desired results - maybe there is a more CI-supported solution that doesn't require hooks or core hacking.




Theme © iAndrew 2016 - Forum software by © MyBB