ezDB is a lightweight library that provides an easy and fast to deal with databases in PHP. It manages connections, provides a query builder, and a lightweight ORM.

1.0.0 2022-07-03 10:54 UTC

This package is auto-updated.

Last update: 2024-05-30 00:42:07 UTC


README

Latest Version on Packagist Total Downloads ezDB Tests Software License

Notice

This branch contains the latest release of ezDB v1.0. This version is not fully compatible with v0.1 and is also not fully compatible with Laravel Eloquent.

v1.0 only supports PHP 8.1, and it should support PHP 8.2 on release.

Please find v0.1 from here.

Description

ezDB is a lightweight library that provides an easy and fast to deal with databases in PHP. It manages connections, provides a query builder, and a lightweight ORM.

This project was inspired by ezSQL and Laravel Eloquent. It borrows most of its syntax from Eloquent and I would like to thank all the awesome developers that worked have worked on it.

The ORM in this library is lightweight and focuses on providing basic functionalities. If you require more functions you can easily extend the library or use a PHP ORM like DoctrineORM.

Install

With Composer

ezDB can be installed using composer by running the command below,

composer require terminusstudio/ezdb

and require the autoload.php file in your script.

require_once __DIR__ . '/vendor/autoload.php';

Without Composer

ezDB can also be included manually. This is very useful for simple projects that only wants to use ezDB for managing database connections.

Follow the steps below:

  1. Download the latest release from here.
  2. Extract the ezDB folder to your project.
  3. In your program include the following line,
require_once '<PATH TO ezDB>/load.php';
  1. This will include all the files that are necessary for ezDB to function. To improve performance, create a copy of load.php and include only the classes that you will use.

How ezDB Works

ezDB can be seperated into three different parts,

  1. Builder
  2. Connection
  3. Model

The Builder (along with the Processor) are at the core of ezDB. They support generating the SQL queries from code.

The Connection classes allow you to manage database connections using multiple drivers and processors. Support queries, prepared statements etc. A global class manages as many connection to as many database as you need. The connections class also supports the IConnectionAwareBuilder which extends the builders and provides support to directly interact with the database from the builder.

Finally, the Model layer provides a basic ORM and is also capable of managing relationships. It uses the Connection classes, and it's custom builders, ModelAwareBuilder (which extends from ConnectionAwareBuilder) and RelationshipBuilder. It supports more features like timestamps, relationship querying, eager loading etc.

License

Copyright © Terminus Studio

Licensed under the MIT license, see LICENSE.md for details.