PHP CodeIgniter Database Wrapper: Access database using CodeIgniter database library

Recommend this page to a friend!
  Info   Example   View files (98)   Download .zip   Reputation   Support forum (3)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 142 All time: 8,933 This week: 237
Version License PHP version Categories
core-php-wrapper-lib 1.0Custom (specified...5PHP 5, Databases
Description Author

This package can access database using CodeIgniter database library.

It provides the database access library like CodeIgniter 3 framework but without having to use that framework. Currently it supports MySQL, MySQLi, PostgreSQL, ODBC, Microsoft SQL Server, SQLite, OCI8 databases.

The package can take an array of configuration options as parameter and initializes the main database access class object.

The database object can perform regular database access operations using a fluent interface to specify create, retrieve, update and delete operations as well functions to specify tables, fields, field values, conditions, etc..

Innovation Award
PHP Programming Innovation award winner
July 2019
Winner
CodeIgniter is a very popular framework used by many applications written in PHP.

Like many other frameworks it comes with a database abstraction library that allows accessing many different types of SQL based databases with the same function calls.

This package allows developers to use a database abstraction library without having to use the CodeIgniter framework as a whole.

Manuel Lemos
Picture of Arumugam P
  Performance   Level  
Name: Arumugam P <contact>
Classes: 4 packages by
Country: India India
Age: 30
All time rank: 3317225 in India India
Week rank: 771 63 in India India
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

Details

CodeIgniter Database

Use the Database Library separately from CodeIgniter 3.

Installation

With Composer

"require": {
    "astute/CodeIgniterDB": "^1.0"
}

or with command line : composer require astute/CodeIgniterDB

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 astute\CodeIgniterDB as CI;
$db_data = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'my_name',
	'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 <a href="http://www.codeigniter.com/userguide3/database/index.html">CodeIgniter user guide</a>.

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 ! Method 1 (Direct call)

<?php
use astute\CodeIgniterDB as CI;

$db_data = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'root',
	'password' => 'my_name',
	'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);

Method 2 (Config file to call the object only) Config.php

<?php 
include('src/DB.php');
use astute\CodeIgniterDB as CI;
$db_data = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'my_name',
	'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
);
$db =& CI\DB($db_data);

index.php Calling the database object by config.php file

<?php
include('config.php');
$result1 = $db->get('table_name')->row();

$result2 = $db->select('columName')->get('table_name')->row();.

$result3 = $db->select('columName')->where('columName',1)->get('table_name')->row();
print_r($result1);
echo '<br>';
print_r($result2);
echo '<br>';
print_r($result3);
  Files  
File Role Description
src (8 files, 1 directory)
config.php Conf. Configuration script
index.php Example Example script
LICENSE Lic. License text
README.md Doc. Read Me

  Files  /  src  
File Role Description
drivers (1 file, 12 directories)
   DB.php Class Class source
   DB_cache.php Class Class source
   DB_driver.php Class Class source
   DB_forge.php Class Class source
   DB_query_builder.php Class Class source
   DB_result.php Class Class source
   DB_utility.php Class Class source
   index.html Doc. Documentation

  Files  /  src  /  drivers  
File Role Description
cubrid (5 files)
ibase (5 files)
mssql (5 files)
mysql (5 files)
mysqli (5 files)
oci8 (5 files)
odbc (5 files)
pdo (5 files, 1 directory)
postgre (5 files)
sqlite (5 files)
sqlite3 (5 files)
sqlsrv (5 files)
   index.html Doc. Documentation

  Files  /  src  /  drivers  /  cubrid  
File Role Description
   cubrid_driver.php Class Class source
   cubrid_forge.php Class Class source
   cubrid_result.php Class Class source
   cubrid_utility.php Class Class source
   index.html Doc. Documentation

  Files  /  src  /  drivers  /  ibase  
File Role Description
   ibase_driver.php Class Class source
   ibase_forge.php Class Class source
   ibase_result.php Class Class source
   ibase_utility.php Class Class source
   index.html Doc. Documentation

  Files  /  src  /  drivers  /  mssql  
File Role Description
   index.html Doc. Documentation
   mssql_driver.php Class Class source
   mssql_forge.php Class Class source
   mssql_result.php Class Class source
   mssql_utility.php Class Class source

  Files  /  src  /  drivers  /  mysql  
File Role Description
   index.html Doc. Documentation
   mysql_driver.php Class Class source
   mysql_forge.php Class Class source
   mysql_result.php Class Class source
   mysql_utility.php Class Class source

  Files  /  src  /  drivers  /  mysqli  
File Role Description
   index.html Doc. Documentation
   mysqli_driver.php Class Class source
   mysqli_forge.php Class Class source
   mysqli_result.php Class Class source
   mysqli_utility.php Class Class source

  Files  /  src  /  drivers  /  oci8  
File Role Description
   index.html Doc. Documentation
   oci8_driver.php Class Class source
   oci8_forge.php Class Class source
   oci8_result.php Class Class source
   oci8_utility.php Class Class source

  Files  /  src  /  drivers  /  odbc  
File Role Description
   index.html Doc. Documentation
   odbc_driver.php Class Class source
   odbc_forge.php Class Class source
   odbc_result.php Class Class source
   odbc_utility.php Class Class source

  Files  /  src  /  drivers  /  pdo  
File Role Description
subdrivers (25 files)
   index.html Doc. Documentation
   pdo_driver.php Class Class source
   pdo_forge.php Class Class source
   pdo_result.php Class Class source
   pdo_utility.php Class Class source

  Files  /  src  /  drivers  /  pdo  /  subdrivers  
File Role Description
   index.html Doc. Documentation
   pdo_4d_driver.php Class Class source
   pdo_4d_forge.php Class Class source
   pdo_cubrid_driver.php Class Class source
   pdo_cubrid_forge.php Class Class source
   pdo_dblib_driver.php Class Class source
   pdo_dblib_forge.php Class Class source
   pdo_firebird_driver.php Class Class source
   pdo_firebird_forge.php Class Class source
   pdo_ibm_driver.php Class Class source
   pdo_ibm_forge.php Class Class source
   pdo_informix_driver.php Class Class source
   pdo_informix_forge.php Class Class source
   pdo_mysql_driver.php Class Class source
   pdo_mysql_forge.php Class Class source
   pdo_oci_driver.php Class Class source
   pdo_oci_forge.php Class Class source
   pdo_odbc_driver.php Class Class source
   pdo_odbc_forge.php Class Class source
   pdo_pgsql_driver.php Class Class source
   pdo_pgsql_forge.php Class Class source
   pdo_sqlite_driver.php Class Class source
   pdo_sqlite_forge.php Class Class source
   pdo_sqlsrv_driver.php Class Class source
   pdo_sqlsrv_forge.php Class Class source

  Files  /  src  /  drivers  /  postgre  
File Role Description
   index.html Doc. Documentation
   postgre_driver.php Class Class source
   postgre_forge.php Class Class source
   postgre_result.php Class Class source
   postgre_utility.php Class Class source

  Files  /  src  /  drivers  /  sqlite  
File Role Description
   index.html Doc. Documentation
   sqlite_driver.php Class Class source
   sqlite_forge.php Class Class source
   sqlite_result.php Class Class source
   sqlite_utility.php Class Class source

  Files  /  src  /  drivers  /  sqlite3  
File Role Description
   index.html Doc. Documentation
   sqlite3_driver.php Class Class source
   sqlite3_forge.php Class Class source
   sqlite3_result.php Class Class source
   sqlite3_utility.php Class Class source

  Files  /  src  /  drivers  /  sqlsrv  
File Role Description
   index.html Doc. Documentation
   sqlsrv_driver.php Class Class source
   sqlsrv_forge.php Class Class source
   sqlsrv_result.php Class Class source
   sqlsrv_utility.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:142
This week:0
All time:8,933
This week:237
User Comments (4)
Its a wonderful package to use CI core database facilities.
11 months ago ( Vikram Jeet Singh)
80%
Very useful package
0 years ago (Arumugam P)
77%
Very useful package
0 years ago (Arumugam P)
77%
Very useful package
0 years ago (Arumugam P)
77%
 

For more information send a message to info at phpclasses dot org.