Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 1.25 KB

README.md

File metadata and controls

52 lines (37 loc) · 1.25 KB

minphp/Db

Build Status Coverage Status

Database Connection Library.

Efficiently manages a connection, preventing a new one from being established if a matching connection already exists.

Installation

Install via composer:

composer require minphp/db:dev-master

Basic Usage

use Minphp\Db\PdoConnection;

$dbInfo = array(
    'driver' => 'mysql',
    'host' => 'localhost',
    'database' => 'databasename',
    'user' => 'user',
    'pass' => 'pass'
);

$connection = new PdoConnection($dbInfo);
$connection->query('SELECT * FROM table WHERE id=?', 1);

Explicitly Connecting

By default, PdoConnection will only connect to the database when a connection is required. To explicitly connect to the database use connect():

use Minphp\Db\PdoConnection;

$dbInfo = array(
    'driver' => 'mysql',
    'host' => 'localhost',
    'database' => 'databasename',
    'user' => 'user',
    'pass' => 'pass'
);

$connection = new PdoConnection($dbInfo);
$connection->connect();
// Connection now ready and waiting