pilulka/database

This package is abandoned and no longer maintained. No replacement package was suggested.

Pilulka Database package is ORM abstraction layer made on top of NotORM database layer.

v1.0.0 2016-07-05 09:38 UTC

This package is not auto-updated.

Last update: 2021-04-03 08:07:32 UTC


README

Author Build Status Software License

SensioLabsInsight

Pilulka Database is database abstraction layer based on the of NotORM library. Let you to create models to use them in domain logic and use NotORM as clever query builder.

Usage example

Let's define some models

class Application extends Model
{
    protected $table = 'application';

    public function getAuthor()
    {
        return $this->getRelated(Author::class);
    }

    public function getApplicationTags($filter=[])
    {
        return $this->getRelatedMany(ApplicationTag::class, $filter);
    }

// ...

}

class Author extends Model
{
   protected $table = 'author';

   /**
    * @param array $filter
    * @return Application[]
    */
   public function getApplications($filter = [])
   {
       return $this->getRelatedMany(Application::class, $filter);
   }

// ...

}   

class Tag extends Model
{
    protected $table = 'tag';

// ...

}

and now use them

// very simple usage
$applications = Application::where('author.full_name like ?', '%David');
foreach($applications as $application) {
    echo "{$application->title} created by {$application->getAuthor()->name}\n";
}

this usage makes only 2 requests to database (no matter how many applications are loaded).

Documentation

Coming soon.