2017 © Pedro Peláez
 

library db-connector

Fork of illuminate/database to provide a simple package for database connection alone

image

robclancy/db-connector

Fork of illuminate/database to provide a simple package for database connection alone

  • Thursday, April 11, 2013
  • by Robbo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 116 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP Database Connector

This package is simply a fork of http://github.com/illuminate/database to just provide the connectors., (*1)

Build Status, (*2)

Installation

Add the following to the "require" section of your composer.json file:, (*3)

    "robclancy/db-connector": "1.0.x"

Basic Usage

You will need a config array, the following shows what can be used..., (*4)

$config = array(

    'fetch' => PDO::FETCH_CLASS,

    // SQLite
    'database' => __DIR__.'/../database/production.sqlite',
    'prefix'   => '',

    // MySQL
    'host'      => 'localhost',
    'database'  => 'database',
    'username'  => 'root',
    'password'  => '',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',

    // Postgres SQL
    'host'     => 'localhost',
    'database' => 'database',
    'username' => 'root',
    'password' => '',
    'charset'  => 'utf8',
    'prefix'   => '',
    'schema'   => 'public',

    // SQL Server
    'driver'   => 'sqlsrv',
    'host'     => 'localhost',
    'database' => 'database',
    'username' => 'root',
    'password' => '',
    'prefix'   => '',
);

And then to make your connection..., (*5)


$connector = new Robbo\DbConnector\MysqlConnector; $pdo = $connector->connect($config);

To make things a little easier and more flexible for applications that support multiple database types you can use a factory method to connect. The config stays the same however you add a driver as well. For example..., (*6)


$config = array( 'driver' => 'mysql', // For other types this is 'pgsql', 'sqlite' or 'sqlsrv' 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', );

Then use the factor like so..., (*7)


$connector = Robbo\DbConnector\Connector::create($config); // Instance of Robbo/DbConnector/MySqlConnector $pdo = $connector->connect($config); // You can also have the factory connect for you by passing true as the second parameter, so... $pdo = Robbo\DbConnector\Connector::create($config, true);

The Versions

11/04 2013

dev-master

9999999-dev

Fork of illuminate/database to provide a simple package for database connection alone

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar Robbo

database sql