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.
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).
Coming soon.