I have a PHP application which is pretty simple: It allows the user to create, edit and read a post. Basic stuff.
I have a
Database class which handles the connection and the queries execution. The thing is that I want my models (I am using a self-built MVC framework) to be clean, so I created in
Database some functions such as
EditPost() etc., which contains all the SQL needed, so I can call them nicely from the model:
$database->CreatePost(/* post data */);.
Should I keep those functions in the
Database class, or should I put them elsewhere (let's say, a class)? Maybe I should even give up on the functions idea and write the code explicitly in the model?
the answer is probably opinion-based, but still - I am trying to figure out what most of the people would do according to well-accepted modern conventions.