danek / grimoire-db
Grimoire is a PHP library for simple working with data in the database.
dev-main
2024-09-04 20:34 UTC
Requires
- php: >=7.1.0
- ext-json: *
- ext-mysqli: *
- psr/simple-cache: ^1.0.1
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-11-04 20:50:30 UTC
README
Grimoire is a PHP library for simple working with data in the database. The most interesting feature is a very easy work with table relationships. The overall performance is also very important and Grimoire can actually run faster than a native driver.
Contents
Requirements
- PHP 7.1+
- only MySQL database supported
Installation
composer require danek/grimoire-db
Usage
<?php $connection = new \Mysqli(...); $config = Grimoire\Config::build($connection); $software = new Grimoire\Database($config); foreach ($software->table('application')->order("title") as $application) { // get all applications ordered by title echo $application['title'] . "\n"; // print application title echo $application->ref('author')['name'] . "\n"; // print name of the application author foreach ($application->related('application_tag') as $application_tag) { // get all tags of $application echo $application_tag->ref('tag')['name'] . "\n"; // print the tag name } }