PHP code example of codeigniter-db / codeigniter-standalone-db

1. Go to this page and download the library: Download codeigniter-db/codeigniter-standalone-db library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codeigniter-db / codeigniter-standalone-db example snippets


// Autoload files using Composer autoload
ase as CodeigniterDatabase;

//Database configuration
$db_data = array(
	'dsn'	=> '',
	'hostname' => '127.0.0.1',
	'username' => 'root',
	'password' => '',
	'database' => 'test',
	'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
);

$obj = new CodeigniterDatabase($db_data);

//Regular Queries
$res = $obj->db->query('select * from products')->result_array();

print_r($res);