Search code examples
phpmysqldatabaseoopobject-oriented-database

SQL queries or object-oriented design?


I'm working on a large-scale website project. Currently the website is setup so that SQL queries are made to databases to manipulate them (e.g. if you want to add a user to the user table you would make an INSERT query).

I'm considering changing the structure to a more object-oriented design. So, there might be a Users class or a Products class. However in this structure, the data would still be stored in a database, so there would be little point in having, for example, a User class (holding each user's individual information). What is the benefit to a object-oriented design like this with a large PHP-MySQL based website?

As you can see, I'm new to structuring large-scale websites. What is the industry-standard for a PHP-MySQL based site? What is the common approach?


Solution

  • What you are alluding to is called an Object-Relational Mapping (ORM). I'd suggest Laravel's Eloqent http://laravel.com/docs/eloquent. But there are many others that dont require frameworks.