Welcome Guest, Not a member yet? Register   Sign In
[Solved] Profiler only shows queries to one database
#7

[eluser]slowgary[/eluser]
In my application I don't need 2 connections, but I do need to replace the connection with a high privileged database user after login. If this helps anyone, here's how I've done it:
Code:
// config/database.php
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "192.168.0.50";
$db['default']['username'] = "visitor";
$db['default']['password'] = "password";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "mysql";
$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";

$db['privileged']['hostname'] = "192.168.0.50";
$db['privileged']['username'] = "admin";
$db['privileged']['password'] = "admin_password";
$db['privileged']['database'] = "";
$db['privileged']['dbdriver'] = "mysql";
$db['privileged']['dbprefix'] = "";
$db['privileged']['pconnect'] = TRUE;
$db['privileged']['db_debug'] = TRUE;
$db['privileged']['cache_on'] = FALSE;
$db['privileged']['cachedir'] = "";
$db['privileged']['char_set'] = "utf8";
$db['privileged']['dbcollat'] = "utf8_general_ci";


// base controller
// grab past query data from existing database object
$queries    = $this->db->queries;
$query_times    = $this->db->query_times;

// overwrite database object with new, higher privileged object
$this->db = $this->load->database('privileged', TRUE);

// add queries back to new object
$this->db->queries        = $queries;
$this->db->query_times        = $query_times;

// go about our merry way



This worked for me. I hope this helps someone else on the hunt.


Messages In This Thread
[Solved] Profiler only shows queries to one database - by El Forum - 06-29-2010, 08:56 AM
[Solved] Profiler only shows queries to one database - by El Forum - 06-29-2010, 09:16 AM
[Solved] Profiler only shows queries to one database - by El Forum - 06-29-2010, 10:12 AM
[Solved] Profiler only shows queries to one database - by El Forum - 06-29-2010, 10:37 AM
[Solved] Profiler only shows queries to one database - by El Forum - 06-29-2010, 11:05 AM
[Solved] Profiler only shows queries to one database - by El Forum - 06-29-2010, 11:14 AM
[Solved] Profiler only shows queries to one database - by El Forum - 10-12-2010, 10:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB