qwant50/dbconnect

Jazz framework DbConnect component

1.0.0 2016-06-13 18:44 UTC

This package is not auto-updated.

Last update: 2024-05-11 17:07:04 UTC


README

Most popular framework DbConnect component

Override

This is a factory PDO based class. Can store multiple instances of connections. Simple and useful.

Installation

The preferred way to install this Jazz framework DbConnect component is through composer.

Either run

php composer.phar require "qwant50/dbconnect"

or add

"qwant50/dbconnect": "~1.*.*"

to the require section of your composer.json.

##Usage

Get instance

$db = DbConnect::getInstance(['connectionName' => 'db1',
                              'host' => '127.0.0.1',
                              'dbname' => 'test',
                              'username' => 'webuser',
                              'password' => 'xxxxxxxx',]);

Get connection

$db = DbConnect::getInstance(['connectionName' => 'db1',
                              'host' => '127.0.0.1',
                              'dbname' => 'test',
                              'username' => 'webuser',
                              'password' => 'xxxxxxxx',])->getConnection();

Example to usage

$db = DbConnect::getInstance(['connectionName' => 'db1',
                              'host' => '127.0.0.1',
                              'dbname' => 'test',
                              'username' => 'webuser',
                              'password' => 'xxxxxxxx',])->getConnection();
$stmt = $db->prepare("SELECT * FROM table_name WHERE login = :login");
$stmt->bindParam(':login', $login);
$stmt->execute();