Skip to content

PilulkaDistribuce/database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pilulka database package

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages