Multiple database pada datamapper (CodeIgniter)


Menggunakan multiple database pada Datamapper:

1. Pada file /application/config/database.php pastikan telah dikonfigurasi group database. Masing-masing group database mewakili database yang dipergunakan dalam aplikasi.
Contoh :
$db[‘default’][‘hostname’] = ‘localhost’;
$db[‘default’][‘username’] = ‘username1’;
$db[‘default’][‘password’] = ‘password1’;
$db[‘default’][‘database’] = ‘database1’;

$db[‘secondg’][‘hostname’] = ‘localhost’;
$db[‘secondg’][‘username’] = ‘username2’;
$db[‘secondg’][‘password’] = ‘password2’;
$db[‘secondg’][‘database’] = ‘database2’;

2. Pada model yang mengekstensi Datamapper assign nama group pada $db_params
$db_params = ‘secondg’;

//$db_params adalah parameter konfigurasi datamapper

About abunajiyah
A Programmer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: