Connect Database Mysql Codeigniter 3

Bekerja menggunakan database mysql di PHP Codeigniter mudah cukup seting file koneksi selesai.

Akses file : application > conifg > database.php

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

$active_group = 'default';

$query_builder = TRUE;

$db['default'] = array(

'dsn'=> '',

'hostname' => 'localhost',

'username' => '_isi username mysql',

'password' => '_isi pass mysql',

'database' => '_isi nama mysql',

'dbdriver' => 'mysqli',

'dbprefix' => '',

'pconnect' => FALSE,

'db_debug' => (ENVIRONMENT !== 'production'),

'cache_on' => FALSE,

'cachedir' => 'application/cache',

'char_set' => 'utf8',

'dbcollat' => 'utf8_general_ci',

'swap_pre' => '',

'encrypt' => FALSE,

'compress' => FALSE,

'stricton' => FALSE,

'failover' => array(),

'save_queries' => FALSE

);

Seting libraries load database, tambahkan value array ‘database’ : application > config > autoload.php

$autoload['libraries'] = array('database');
READ :  Allow Setup Remote Connection to Mysql