PHP Classes
elePHPant
Icontem

PHP CodeIgniter Database Wrapper: Access database using CodeIgniter database library

Recommend this page to a friend!
  Info   View files Example   View files View files (98)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-07-08 (24 days ago) RSS 2.0 feedNot enough user ratingsTotal: 56 This week: 3All time: 9,520 This week: 76Up
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 nominee
July 2019
Nominee
Vote
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
  Performance   Level  
Name: Arumugam P <contact>
Classes: 4 packages by
Country: India India
Innovation award
Innovation award
Nominee: 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 folder image Files  
File Role Description
Files folder imagesrc (8 files, 1 directory)
Plain text file config.php Conf. Configuration script
Plain text file index.php Example Example script
Plain text file LICENSE Lic. License text
Plain text file README.md Doc. Read Me

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

  Files folder image Files  /  src  /  drivers  
File Role Description
Files folder imagecubrid (5 files)
Files folder imageibase (5 files)
Files folder imagemssql (5 files)
Files folder imagemysql (5 files)
Files folder imagemysqli (5 files)
Files folder imageoci8 (5 files)
Files folder imageodbc (5 files)
Files folder imagepdo (5 files, 1 directory)
Files folder imagepostgre (5 files)
Files folder imagesqlite (5 files)
Files folder imagesqlite3 (5 files)
Files folder imagesqlsrv (5 files)
  HTML file index.html Doc. Documentation

  Files folder image Files  /  src  /  drivers  /  cubrid  
File Role Description
  Plain text file cubrid_driver.php Class Class source
  Plain text file cubrid_forge.php Class Class source
  Plain text file cubrid_result.php Class Class source
  Plain text file cubrid_utility.php Class Class source
  HTML file index.html Doc. Documentation

  Files folder image Files  /  src  /  drivers  /  ibase  
File Role Description
  Plain text file ibase_driver.php Class Class source
  Plain text file ibase_forge.php Class Class source
  Plain text file ibase_result.php Class Class source
  Plain text file ibase_utility.php Class Class source
  HTML file index.html Doc. Documentation

  Files folder image Files  /  src  /  drivers  /  mssql  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file mssql_driver.php Class Class source
  Plain text file mssql_forge.php Class Class source
  Plain text file mssql_result.php Class Class source
  Plain text file mssql_utility.php Class Class source

  Files folder image Files  /  src  /  drivers  /  mysql  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file mysql_driver.php Class Class source
  Plain text file mysql_forge.php Class Class source
  Plain text file mysql_result.php Class Class source
  Plain text file mysql_utility.php Class Class source

  Files folder image Files  /  src  /  drivers  /  mysqli  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file mysqli_driver.php Class Class source
  Plain text file mysqli_forge.php Class Class source
  Plain text file mysqli_result.php Class Class source
  Plain text file mysqli_utility.php Class Class source

  Files folder image Files  /  src  /  drivers  /  oci8  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file oci8_driver.php Class Class source
  Plain text file oci8_forge.php Class Class source
  Plain text file oci8_result.php Class Class source
  Plain text file oci8_utility.php Class Class source

  Files folder image Files  /  src  /  drivers  /  odbc  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file odbc_driver.php Class Class source
  Plain text file odbc_forge.php Class Class source
  Plain text file odbc_result.php Class Class source
  Plain text file odbc_utility.php Class Class source

  Files folder image Files  /  src  /  drivers  /  pdo  
File Role Description
Files folder imagesubdrivers (25 files)
  HTML file index.html Doc. Documentation
  Plain text file pdo_driver.php Class Class source
  Plain text file pdo_forge.php Class Class source
  Plain text file pdo_result.php Class Class source
  Plain text file pdo_utility.php Class Class source

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

  Files folder image Files  /  src  /  drivers  /  postgre  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file postgre_driver.php Class Class source
  Plain text file postgre_forge.php Class Class source
  Plain text file postgre_result.php Class Class source
  Plain text file postgre_utility.php Class Class source

  Files folder image Files  /  src  /  drivers  /  sqlite  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file sqlite_driver.php Class Class source
  Plain text file sqlite_forge.php Class Class source
  Plain text file sqlite_result.php Class Class source
  Plain text file sqlite_utility.php Class Class source

  Files folder image Files  /  src  /  drivers  /  sqlite3  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file sqlite3_driver.php Class Class source
  Plain text file sqlite3_forge.php Class Class source
  Plain text file sqlite3_result.php Class Class source
  Plain text file sqlite3_utility.php Class Class source

  Files folder image Files  /  src  /  drivers  /  sqlsrv  
File Role Description
  HTML file index.html Doc. Documentation
  Plain text file sqlsrv_driver.php Class Class source
  Plain text file sqlsrv_forge.php Class Class source
  Plain text file sqlsrv_result.php Class Class source
  Plain text file sqlsrv_utility.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:56
This week:3
All time:9,520
This week:76Up