othercode/database

Database access library

v2.0 2017-05-08 20:44 UTC

This package is auto-updated.

Last update: 2024-10-30 01:26:35 UTC


README

Build Status Latest Stable Version License Total Downloads

Light database abstraction layer (PDO)

Currently supported:

  • MySQL
  • SQLite
  • Postgres

Installation

To install the package we only have to add the dependency to composer.json file:

"require": {
  "othercode/database": "*"
}

And run the following command:

composer update

Install without Composer

Also we can use this library without Composer, we only have to include in our script the "database/autoload.php" file.

require_once "database/autoload.php".

Configuration

Now we have to create the instance and add a new connection to it.

$db = new OtherCode\Database\Database();

$db->addConnection(array(
    'driver' => 'mysql',
    'host' => 'localhost',
    'dbname' => 'test',
    'username' => 'username',
    'password' => 'password'
));