What is the ideal model for creating classes involving the database?

Asked

Viewed 33 times

1

I have a very strong question about what is the best way to create classes to "interact" with the database (in PHP, in this case). For example:

I need very specific validations of each table to be executed before registering something in the database.

So it’s ideal to create classes like: Insert, Update e Delete? Or should all of these actually be Database class methods? Or would it be better to create each method of this for each model (MVC) of my project?

Anyway, what would be the best way to do this?

Thank you!

  • There is a lot of opinion of each one. I, for example, think that to use DB in PHP the ideal is not to create any class and use what is already ready. Others may think differently.

  • About the Database, I think that ORM might bring some light. Usually each model has its own methods that may or may not use BD - there are operations in the model that can generate text log.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.