CodeIgniter Forums

Full Version: Model without Database?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I've just started playing with CI and from what I've seen thus far, I'm very enthusiastic about transitioning some of my own home-brew MVC code over to something more manageable.

However, I do have a question... I basically have an app that needs to query against a good bit of data which resides in flat files. I already have some code to do all of this and get the data of them, however I'm not sure of the appropriate place to put this logic?

I would consider this code to be my app's model, but it appears that I get added database code by sub-classing Model (as a bit of an aside, are there API docs describing these built-in superclasses, or should I just look at the source?). So, I'm not sure that sub-classing Model is appropriate here. From looking at the guide, a CI Helper also seems appropriate.

Your feedback/thoughts are appreciated.



El Forum

Nothing in the Model base class forces a database connection, and the Model Loader does not load the database by default, so it seems you should be good to go, creating your Models to access flat files.

El Forum

if you want to implement your code clean you could add a new driver to the database directory and try to mimic the normal database the best you can. This means you could use the AR class and the config/database.php file.

if you want it quick and dirty you add your own library to the libraries folder and load it in the models.

About the added code, as far as i know it's only added if you set the third parameter to true. if you do
it doesn't load extra parameters.

edit : beaten by wiredesignz it must be weekend Wink

El Forum

@xwero: :lol:

Xwero is right, there should be a data access layer (driver) from which the Model can get it's data rather than having to directly load the files itself.