Welcome Guest, Not a member yet? Register   Sign In
Auto Loading Session Issues
#1

[eluser]Eric Barnes[/eluser]
I am trying to build an app that will be installed by the end user and I want to create install steps. So basically if the tables do not exist go to index.php/setup

The problem I am running into is I am auto loading the sessions and a global model which uses CI sessions class. I have it setup to store these in the database. So it always errors out saying the table doesn't exist.

I wanted to ask if anyone had any advice? I know I can manually load these later but that is not really desired since I have lots of files that would need to be edited.

I guess what I am really looking for is a way to over ride the auto loading through a hook or create the table automatically but I don't see this as being possible. pre_controller is to soon and post_controller_constructor is too late. Sad

Any advice is appreciated! Smile
#2

[eluser]Aken[/eluser]
I'm confused - you're trying to autoload things in CI based upon variables in a database?
#3

[eluser]Eric Barnes[/eluser]
Sorry for not explaining very well. Let me try again.

In autoload.php I have the session library autoloaded and the sessions are stored in the databse. So if the table doesn't exist the whole app errors out.

I would like a way to have this remain autoloaded but somehow bypassed if the table doesn't exit. At that point it would forward to an install controller.
#4

[eluser]Aken[/eluser]
Gotcha! I thought it was something along those lines but clarification never hurts.

With that said, I have a possible solution for you. Instead of changing the autoload, why don't you change the config items that call the use of the sessions DB?

The sessions library is autoloaded by default. The user goes through the install controller, and somewhere in that process after the DB has been created, you use the following:

Code:
$this->config->set_item('sess_use_database', TRUE);
You would still need to set the DB name inside the config file (or add another rule right below that one). Also unless you added some more checks for an existing DB, you'd pretty much force the install script all the time. Personally I'd do that anyway - less chances for the end user to mess something up. That way the tables are always created exactly how you want.

Hope that works for you.
#5

[eluser]Eric Barnes[/eluser]
Thanks for the follow up. I ended up getting it working by not autoloading anything. Then creating MY_Controller and have it load all the ones I need. Finally only use it as the parent class in the script files and not the setup.

Now it seems to work perfect. Smile




Theme © iAndrew 2016 - Forum software by © MyBB