Skip to content
Daniel Spors edited this page Nov 4, 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.

Basic classes

There are some basic classes you found be familiar with:

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.

You will of course want to create your own classes with some business logic inside. This is done by extending the Model class:

class MyData extends Model
{
	function GetTablename(){ return 'mytable'; }
}

Note that there's no need of defining the columns. Those are added to objects of type MyData when they are queried from the database.

Clone this wiki locally