Welcome Guest, Not a member yet? Register   Sign In
Is there any way to load routes from DB?
#1

[eluser]Volosatos[/eluser]
Hello everybody!
I need to define routes from database, but the database class loading after route class!
Is it possible some how define them?
#2

[eluser]Phil Sturgeon[/eluser]
You can do it two ways. Include the database config file in the routers file, then use native mysql functions to connect to the db and populate your arrays.

OR

you could try forcing the database class to load a little earlier. Doubt that will work that way as the files are only variable includes arent part of the CI super-object.
#3

[eluser]Volosatos[/eluser]
[quote author="thepyromaniac" date="1202194384"]You can do it two ways. Include the database config file in the routers file, then use native mysql functions to connect to the db and populate your arrays.

OR

you could try forcing the database class to load a little earlier. Doubt that will work that way as the files are only variable includes arent part of the CI super-object.[/quote]

I tried the first way, but unsuccessfully, because variables in database config file, can't be displayed, I don't understand why..
For example, after i include config file, i tried to display this:
Code:
echo $db['default']['hostname'];
but the result is empty!
And it is very difficult to debug it because display errors is OFF. And I can't fine where i can switch in on. In index.php it doesn't work. In my php.ini errors are enabled too.
#4

[eluser]Lone[/eluser]
HINT: Top of database config file Wink

Code:
if (!defined('BASEPATH')) exit('No direct script access allowed');
#5

[eluser]Volosatos[/eluser]
BASEPATH is defined in index.php, so anyway, if you use codeigniter it will be defined, cause every page go through index.php.
#6

[eluser]Phil Sturgeon[/eluser]
If you are directly including config files you will need to define BASEPATH. At least in my experience.

Make sure you turn PHP's error reporting ALL the way up on this too, it should have blank variables without chucking you an error or warning.




Theme © iAndrew 2016 - Forum software by © MyBB