2021/11/08/data objects refactoring
Database instantiation is currently done by
cDatabase::Instantiate(), which uses an internal static table to look up the
cDatabase-descendant to instantiate from a slug returned by
I suddenly realized that this makes no sense:
- the cDatabaseSpec-descendant should just return the class it wants to use, from
cDatabaseSpeccan instantiate directly, e.g.
cDatabaseshould be named
caDatabase, because it is abstract.
Also, Database-spec-class registration is currently done in
ferreteria/data/db/0.php. This made some sense as a stopgap when I wasn't trying to properly handle app-specific databases or db-less tables, but that needs to change.
- replace abstract
- add Database registry to
- AddDatabase(string $sSlug, caDatabase $db)
- GetDatabase(string $sSlug) : caDatabase
- registration of DB-spec classes should happen in a portable overrideable config file -- perhaps in
Note that the same database can (and probably should) be registered until multiple names, for easier separation of roles. For example, if the main database is the default database for application tables and also contains the user-access tables, then it could be registered as "*" (default), "main", and "users".