nguyenanhung/codeigniter-database-standalone

A wrapper database from CodeIgniter

v1.0.3 2024-09-21 17:48 UTC

This package is auto-updated.

Last update: 2024-12-21 18:23:17 UTC


README

Latest Stable Version Total Downloads License PHP Version Require

CodeIgniter ^3.1.11 Database

Use the Database Library separately from CodeIgniter 3.

Installation

With Composer

"nguyenanhung/codeigniter-database-standalone": "^1.0"

or with command line : composer require nguyenanhung/codeigniter-database-standalone

Without Composer

You can also download it from Github, but no autoloader is provided so you'll need to register it with your own PSR-0 compatible autoloader.

Usage

<?php
use nguyenanhung\CodeIgniterDB as CI;
$db_data = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'root',
	'password' => 'my_password',
	'database' => 'my_database',
	'dbdriver' => 'mysqli',
	'dbprefix' => '',
	'pconnect' => FALSE,
	'db_debug' => TRUE,
	'cache_on' => FALSE,
	'cachedir' => '',
	'char_set' => 'utf8',
	'dbcollat' => 'utf8_general_ci',
	'swap_pre' => '',
	'encrypt' => FALSE,
	'compress' => FALSE,
	'stricton' => FALSE,
	'failover' => array(),
	'save_queries' => TRUE
);
$oDb =& CI\DB($db_data);

For more information visit CodeIgniter user guide.

Custom option

I've added the possibility to give a mysql ressource to reuse a already opened connection. Thus to not multiply connections and to use this in parallel with legacy code and proceed to a migration step by step. Works only with the mysql driver !

<?php
use nguyenanhung\CodeIgniterDB as CI;

$db_data = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'root',
	'password' => 'my_password',
	'database' => 'my_database',
	'dbdriver' => 'mysql',
	'dbprefix' => '',
	'pconnect' => FALSE,
	'db_debug' => TRUE,
	'cache_on' => FALSE,
	'cachedir' => '',
	'char_set' => 'utf8',
	'dbcollat' => 'utf8_general_ci',
	'swap_pre' => '',
	'encrypt' => FALSE,
	'compress' => FALSE,
	'stricton' => FALSE,
	'failover' => array(),
	'save_queries' => TRUE
);

$rDb = mysql_connect($db_data['hostname'], $db_data['root'], $db_data['password']);

$oDb =& CI\DB($db_data, null, $rDb);

Contact

If any question & request, please contact following information

From Hanoi with Love <3