Welcome Guest, Not a member yet? Register   Sign In
Problem Multiples Connection Database
#1

[eluser]Mellkior[/eluser]
Hi,

I have 3 databases in my work.

2 Mssql and 1 mysql

Not ask why the 3.... hehehe.

database.php
Code:
$active_group = "default";
$active_record = TRUE;

// MSSQL
$db['default']['hostname'] = "*******";
$db['default']['username'] = "********";
$db['default']['password'] = "********";
$db['default']['database'] = "********";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

// MYSQL
$db['mysql']['hostname'] = "*******";
$db['mysql']['username'] = "*******";
$db['mysql']['password'] = "*******";
$db['mysql']['database'] = "*******";
$db['mysql']['dbdriver'] = "mysql";
$db['mysql']['dbprefix'] = "";
$db['mysql']['pconnect'] = TRUE;
$db['mysql']['db_debug'] = TRUE;
$db['mysql']['cache_on'] = FALSE;
$db['mysql']['cachedir'] = "";
$db['mysql']['char_set'] = "utf8";
$db['mysql']['dbcollat'] = "utf8_general_ci";

// MSSQL 2
$db['othermssql']['hostname'] = "*******";
$db['othermssql']['username'] = "*******";
$db['othermssql']['password'] = "*******";
$db['othermssql']['database'] = "*******";
$db['othermssql']['dbdriver'] = "mssql";
$db['othermssql']['dbprefix'] = "";
$db['othermssql']['pconnect'] = TRUE;
$db['othermssql']['db_debug'] = TRUE;
$db['othermssql']['cache_on'] = FALSE;
$db['othermssql']['cachedir'] = "";
$db['othermssql']['char_set'] = "utf8";
$db['othermssql']['dbcollat'] = "utf8_general_ci";

On system/codeigniter/Codeigniter.php

Code:
$CI->db->close();

close only my default database.

Others 2 connections stay opened.

How can i close all my connections in database?

Thanks!
#2

[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...cting.html

Quote:When you connect this way, you will use your object name to issue commands rather than the syntax used throughout this guide. In other words, rather than issuing commands with:

$this->db->query();
$this->db->result();
etc...

You will instead use:

$DB1->query();
$DB1->result();
etc...
#3

[eluser]Mellkior[/eluser]
But how close the 3 databases on Codeigniter.php?

Try
Code:
$CI->db->close(); // Works, this close default database only.
$CI->mysql->close(); // Error
$CI->othermssql->close(); // Error
#4

[eluser]danmontgomery[/eluser]
That depends on how you open them

Code:
$db1 = $this->load->database('default', TRUE);
$db2 = $this->load->database('mysql', TRUE);
$db3 = $this->load->database('othermssql', TRUE);

// ...

$db1->close();
$db2->close();
$db3->close();
#5

[eluser]Mellkior[/eluser]
Solved

Change in database.php

Code:
$db['default']['pconnect'] = TRUE;

For

Code:
$db['default']['pconnect'] = FALSE;

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB