Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter models
#1

[eluser]TheFuzzy0ne[/eluser]
Hi everyone. I'm currently looking to find the best way for me to code my models, as I am aware there are different methods.

First of all, I have a simple application, and the controller is named "recommended_resources". Basically, a user can add various categories, and under them, they can add as many resources as they like. A resource contains an id, category id, a title, a URL and a description.

I am unsure how to separate my models (if at all). I was thinking of having separate CRUD models for categories, and resources. Seems simple enough, but I'm not so sure if CRUD is the best option. First of all, I don't feel easy about having to potentially reset the models variables each time I use it (if I want to use it more than once). Second of all, I'm not sure how I could generate a filtered page of resources from this model.

By filtered page of resources, I mean that a user should be able to search the resources, and the relevant resources will be displayed. I don't know if this should be seperate for the resources model, as it requires new variables such as filter, start result, end result, category etc...

Would I be complicating things by splitting "resource" and "resource page" into separate models? I don't know whether start result, results per page, and filter should be a part of the resource model, or if it should be part of a separate "resource page" model. Should it not be split up at all, and should categories, resources and resource pages all be part of the "recommended resources" model?

I'm sorry to keep having to call for assistance like this, but I am genuinely stumped and I can't seem to find any information on the Internet to help me out here. It's important to me that I code everything right first time, as I've done too many projects where I've hit a snag, and had to do a lot of code rewriting to get around it.

I would like to hear what methods other people use for building models.
#2

[eluser]jane0109[/eluser]
Im also new with building models and right now testing every way to determine which method is applicable.
#3

[eluser]TheFuzzy0ne[/eluser]
I think I may have discovered my answer.

Each model should represent just one table, or a group of other models.

Obviously not everyone would agree with this, but I think it will work well for me. It's simple, robust, and fairly extensible.




Theme © iAndrew 2016 - Forum software by © MyBB