-
Notifications
You must be signed in to change notification settings - Fork 34
DBAL
DaSpors edited this page Nov 2, 2020
·
5 revisions
The database abstraction layer follows a simple DB-first pattern.
It is in fact a ORM with a high level API, that allows you to query most data in a one-liner
or at least create 'typed' Queries that result in Object lists.
There are two basic classes you found be familiar with:
- DataSource provides database access
- Model is the base class for all models
- CommonModel is an anonymous model class
The DBAL will create properties according to the table definitions found in the database.
This can be as simple as this:
$data = DataSource::Get()->Query('mytable')->like('name','%peter%');
foreach( $data as $entry )
{
// do something
echo "{$data->id}: {$data->name}\n";
}
In this sample the DBAL will create a ResultSet ($data) containing objects of type CommonModel, each with properties for each table column.