biurad/biurad-database

This package is abandoned and no longer maintained. The author suggests using the spiral/database package instead.

DBAL, schema introspection, migration and pagination

v2.7.13 2020-06-22 02:09 UTC

README

Interacting with databases extremely simple across a variety of database backends using either raw SQL, the fluent query builder, and the DBAL. Currently, this package is a fork version of Spiral Database to be used as standalone in any php project.

Please note that you can get the documentation for this dependency on spiral website, database

Documentation

Installation

The recommended way to install Database Manager is via Composer:

composer require biurad/biurad-database

It requires PHP version 7.2 and supports PHP up to 7.4. The dev-master version requires PHP 7.1. Also PDO Extension with desired database drivers.

How To Use

Example

Given example demonstrates the connection to SQLite database, creation of table schema, data insertion and selection:

<?php
declare(strict_types=1);

require_once "vendor/autoload.php";

use BiuradPHP\Database\Config\DatabaseConfig;
use BiuradPHP\Database\DatabaseManager;
use BiuradPHP\Database\Driver\SQLite\SQLiteDriver;

$dbm = new DatabaseManager(new DatabaseConfig([
    'databases'   => [
        'default' => ['connection' => 'sqlite'],
    ],
    'connections' => [
        'sqlite' => [
            'driver'     => SQLiteDriver::class,
            'connection' => 'sqlite:database.db',
        ],
    ],
]));

$users = $dbm->database('default')->table('users');

// create or update table schema
$schema = $users->getSchema();
$schema->primary('id');
$schema->string('name');
$schema->datetime('created_at');
$schema->datetime('updated_at');
$schema->save();

// insert data
$users->insertOne([
    'name'       => 'test',
    'created_at' => new DateTimeImmutable(),
    'updated_at' => new DateTimeImmutable(),
]);

// select data
foreach ($users->select()->where(['name' => 'test']) as $u) {
    print_r($u);
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Testing

To run the tests you'll have to start the included node based server if any first in a separate terminal window.

With the server running, you can start testing.

vendor/bin/phpunit

Security

If you discover any security related issues, please report using the issue tracker. use our example Issue Report template.

Want to be listed on our projects website

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a message on our website, mentioning which of our package(s) you are using.

Post Here: Project Patreons - https://patreons.biurad.com

We publish all received request's on our website.

Credits

Support us

Biurad Lap is a technology agency in Accra, Ghana. You'll find an overview of all our open source projects on our website.

Does your business depend on our contributions? Reach out and support us on to build more project's. We want to build over one hundred project's in two years. Support Us achieve our goal.

Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

Thanks to all who made Donations and Pledges to Us.

License

MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.