minphp / db
Database Connection Library
2.0.1
2015-11-30 22:49 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~2.2
This package is auto-updated.
Last update: 2024-11-20 21:58:34 UTC
README
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