PHP code example of anovsiradj / ci3db

1. Go to this page and download the library: Download anovsiradj/ci3db 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/ */

    

anovsiradj / ci3db example snippets


// IMPORTANT: "BASEPATH" must end with slash or directory separator.
define('BASEPATH', 'path/to/vendor/codeigniter/framework/system/'); // relative
define('BASEPATH', realpath('/path/to/vendor/codeigniter/framework/system') . DIRECTORY_SEPARATOR); // absolute

$ci3db =& \anovsiradj\CI3DataBase::init();

$ci3db->set_db_config_file('path/to/config/database.php'); // see ./tests/cfg.php
// or
$ci3db->set_db_config('db-server-0', array(
	...
	'dbdriver' => '...',
	'hostname' => 'localhost',
	'username' => 'root',
	'password' => 'root',
	'database' => '...',
	...
));
// or
$ci3db->set_db_config('db-server-1', 'dbdriver://username:password@hostname/database');

// Using the query builder
$db =& $ci3db->db(); // or
$db =& $ci3db->db('db-server-0'); // or
$db =& \anovsiradj\CI3DataBase::db(); // or
$db =& \anovsiradj\CI3DataBase::db('db-server-1');