[eluser]goFrendiAsgard[/eluser]
I have a trouble with dbutil and db. Below is my code (a constructor of my model):
Code:
public function __construct(){
// I save my database configuration in CI session
$this->load->library('session');
$config = $this->session->userdata("db_config");
if($config){ // $config is now equal contains of my database configuration
$this->db = $this->load->database($config, TRUE);
}else{
$this->db = $this->load->database();
}
$this->load->dbutil();
echo '<pre>'.print_r($this->db, TRUE).'</pre>';
echo '<pre>'.print_r($this->dbutil, TRUE).'</pre>';
}
I found that $this->db and $this->dbutil point to different databases.
$this->db point to database config from session:
Code:
....
[username] => root
[password] => toor
[hostname] => localhost
[database] => coba
....
While $this->dbutil point to database config from my configuration file (application/config/database.php):
Code:
....
[username] => root
[password] => toor
[hostname] => localhost
[database] => module_devel
....
This is not expected, since I expect both of $this->db and $this->dbutil point to the same database
I've also check PHP: CodeIgniter; Managing two db connections; variable database parameters. But, for me the solution doesn't work at all.
So, anyone can discover what's wrong here? Thanks in advance