Welcome Guest, Not a member yet? Register   Sign In
Best model practise
#1

[eluser]Unknown[/eluser]
Hey Smile
I developed until now a more or less huge project with CI. I really love CI but when I look at my code (models) then I see one problem which occurs ever and ever.

For example: the controller "Articles" has the function "view_article", which uses the model "Articles_model". In the model, I call the function "get_article", which selects data from the articles table. Now, the articles table has the field "author_id", a number. I want to return an array to my controller which contains all of the article data, but: i dont want just the number of the author. I want to get the authors name into the array, so i wrote another function in my model: get_auhtor_name(by_id). Everything is fine BUT: the is not the only controller / model which needs the authors name, so I wrote the same (or a bit different) function in many other models which completely is not the DRY method, or?

So here is the question: should I create a model for each table to decrease repetition? I really dont know the best practise.

I hope you'd understand my question (and sorry for the english, german here Wink)

greetings,
pr4xx


Messages In This Thread
Best model practise - by El Forum - 11-18-2012, 04:00 AM
Best model practise - by El Forum - 11-19-2012, 02:14 PM
Best model practise - by El Forum - 11-19-2012, 10:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB