corviz / database-layer
Standalone library for database interaction
dev-master
2022-08-17 18:32 UTC
Requires
- php: >=8
- ext-pdo: *
- clancats/hydrahon: ^1.1
This package is auto-updated.
Last update: 2024-10-17 22:57:30 UTC
README
Corviz database layer provides a simple yet powerful interface to run your database operations.
We use Hydrahon query builder as it's base components, extending it with a Model. It means that all operations included in their library will be avaliable for your models as well.
Installation
composer require corviz/database-layer
Features
- Simple to use query builder
- Database interface (binding, native queries, transactions, db function execution, etc...)
- Base model that features mutators, accessors and CRUD operations...
- Mass objects creation
And more coming soon!
Have a taste:
Example 1 - Fetch active users:
$users = User::query()->where('active', true)->get(); foreach ($users as $user) { echo $user->id, ' - ', $user->email; }
Example 2 - Create and save a contact:
$contact = new Contact(); $contact->name = 'John'; $contact->phone = '+1 (999) 999-9999'; $contact->insert();
Example 3 - Create messages in the messages table:
Message::create([ [ 'message' => 'This is an warning message', 'level' => 'warning' ], [ 'message' => 'This is an info message', 'level' => 'info' ] ]);