usernane / phMysql

PHP library for building MySQL database schema and quires.
MIT License
4 stars 2 forks source link

Automation of Entity Class Creation #13

Closed usernane closed 4 years ago

usernane commented 4 years ago

Problem

Usually, every table in the database is associated with an entity class. The entity class will mostly have all table columns as an attributes. For each attribute, there must be a public function to set and get the value of the attribute. Currently, the library has a way to map a select result to an entity class. The issue is that the entity class must be created manually by writing the whole entity class's code.

Suggested Solution

As I have said, each database table is usually mapped to an entity. If this is the case, why don't we have a method in the class MySQLTable Which can be used to create the entity class automatically? This would reduce the development effort a lot.

The method signature would be as follows:

The options array should be an associative array. It can have the following indices:

More options can be added in the future to customize the created entity class.