avalon/database

Avalon Database Component

Installs: 880

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

pkg:composer/avalon/database

dev-master / 2.0.x-dev 2018-03-25 06:03 UTC

This package is not auto-updated.

Last update: 2025-09-28 00:29:23 UTC


README

The Avalon database package makes use of the Doctrine Database Abstraction Layer, it is essentially a small wrapper around it that provides a simple "Model" system.

This is not an ORM.

Models

Models are a representation of a database row, you can select, update and delete rows with models.

Selecting rows into models

When using a model to fetch data, it will automatically be placed into a model for you.

class Article extends Avalon\Database\Model {}

$articles = Article::where('is_published = :is_published')
    ->andWhere('user_id = :user_id')
    ->setParameter('is_published', 1)
    ->setParameter('user_id', 5)
    // Normally with Doctrine and PDO you would call `->execute()`,
    // you could do that here, but it would return the statement.
    //
    // If you simply call `fetchAll()` you will get an array of `Article` models.
    ->fetchAll();

foreach ($articles as $article) {
    echo $article->title;
}