With attributes. A DataTable becomes an ObjectTable:
class MyObject {
[#\Id(bigint)]
int $id;
[#Column('some_string', 'varchar(128)')]
string $someString;
[#Column('some_date', 'datetime(6)']
string $someDate;
...
}
Then instead of createRow, getRows, etc
storeObject(int $id, object $myObjectInstance);
getObject(int $id): object; // returns a true MyObject instance, not a stdObject
...
During construction the mapper gets the column to property map using a Reflection class.
It could even check that the database table is properly constructed or generate SQL code to create the table.
With attributes. A DataTable becomes an ObjectTable:
Then instead of createRow, getRows, etc
During construction the mapper gets the column to property map using a Reflection class.
It could even check that the database table is properly constructed or generate SQL code to create the table.