I have been reading a few questions previously asked and I haven't come across one that answers my question in "black and white" for me! So, apologies if this is repetitive. The question is probably similar to asking, "how long is a piece of string" but bear with me!
For a registernation system, I have a user model with functions such as:
The above user model deals with one table. The users table in the MySQL database.
You can guess what each function does but is this coarse enough? I mean should my model contain methods that are much broader such as:
Where I pass in the table and a unique identifier of the record to delete, add or update?
I am using codeigniter, but I am interested in how things should be done in a pure MVC framework.
I apologise if this question is too picky.
Thanks all
I'm not sure what you mean by "coarse".
"should my model contain methods that are much broader such as: add_record, delete_record, update_record"
Absolutely not. Never. That defeats the purpose of having a model.
That kind of "general-purpose" stuff is what a database is for. The point of a model is to adapt the general database to your specific problem.
Your model should be specific to your problem.
"user model with functions such as: add_user, delete_user, activate_user" That's the point. Your model reflects your application, your problem domain, your solution.
Your model should be able to -- in effect -- stand alone. You should be able to wrap your model in a command-line app or a GUI app or a web page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With