Reputation: 1240
I'm currently working on an MVC based PHP project. My script basically will be sending out some emails to clients, and it needs to pull an email template from the database. I've got a mail helper library which provides an interface into the SWIFT Mailer class. For the data related stuff (e.g pulling the email template from the DB) is it bad practice to use a new model (lets call it 'mail_model.php') even though there wont be a mail controller?
A quick overview of the structure:
CONTROLLERS - Client (some emails get sent here) - Invoices (some more emails get sent here)
MODELS - Client - Invoices - Mail
VIEWS - Client - Invoices
HELPERS/LIBRARIES - Clients - Invoices - Mail (interface for SWIFT)
(nb: this is just a dumbed down example)
So yeah, I really just wanted to see if this was a bid no-no or if its ok to be doing this. If its not, does anyone have an alternate way of doing it?
Thanks for your time!
Upvotes: 1
Views: 296
Reputation: 24818
Actually there's no fix correlation from controllers to models.
Models abstract persistent strage (i.e. database) operations, and controllers handle requests.
A controller may use several models for some request and none for another.
Upvotes: 3
Reputation: 321
I don't personally see a problem with having a model that could be used by multiple controllers. But not sure if thats your question, as it's a bit confusing.
Upvotes: 1