Welcome Guest, Not a member yet? Register   Sign In
Creating a Library - Do I use a Model when data is stored in files?
#1

[eluser]SherriW[/eluser]
Hello,

I'm new to CI and I want to learn the ropes by converting one of my simple PHP plugins over to a CI Library. The plugin stores it's data in files. My question is, do I create a Model to handle the data management to/from the files, or are Models only for DB data storage? Am I adding too much complexity by considering a model?

PS- I will want to make my plugin open source so it's best if it is as contained as possible.

Thanks.
#2

[eluser]SherriW[/eluser]
I think I found the answer in here:
http://ellislab.com/forums/viewthread/111233/

I think I will define a class in the Model and that does all the processing, including to and from the file storage.
#3

[eluser]techgnome[/eluser]
Yes... ALL data access whether db or file-based should be done through the model. That's what it's for.

-tg
#4

[eluser]SherriW[/eluser]
I'm thinking I will need a a controller for my script, several views and a model. It's too bad these can't be packaged all together. But I guess when I distribute it I can explain where they go.
#5

[eluser]SherriW[/eluser]
Then again... from the CI docs it seems plugins are meant for code that is shared and can be 'dropped in' to your application. Maybe I will do it like that.
#6

[eluser]techgnome[/eluser]
Except... that as I understand it, plugins are on the way out and won't work in CI2. I know what you mean, it would be nice if a module could just all be in one folder, the controller, models, and views... I *think* that's being done in CI2... but I'm not sure... some of the posts I've read around here seem to lean towards that... but don't take my word for it. Maybe some one else can shed some light on it.

-tg




Theme © iAndrew 2016 - Forum software by © MyBB