I am building a blog based on a self-rolled MVC structure. I want to build my own, not used a 3rd party.
What is the best way to handle the creation of a new blog? Heres two options i can see…which is better, or is there something i haven’t thought of?
-
Instantiate a blank (doesn’t go fetch blog info from db) Blog model, set all the values for the new blog, and then call something like $blog->create() which will do an INSERT instead of UPDATE
-
Have a separate class just for the creation of blog which upon creation returns the new blog object.
What do you think? How do you normally go about the creation process?
If you’re doing MVC, you should have a controller which maps the blog input from the view into a Blog model object. You could have a helper class do this, but it probably won’t be very complicated, so I’d say go with option 1 and have your controller just create the new persistent Blog object.