Welcome Guest, Not a member yet? Register   Sign In
2 databases and libraries
#1

[eluser]Maglok[/eluser]
I have an app where I have a database for the app data and a database from a phpbb forum that provides login data.

In my database.php I have the following:

Code:
/* APP */
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "***";
$db['default']['username'] = "***";
$db['default']['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";

/* FORUM */
$active_group = "forum";
$active_record = TRUE;

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

I also extended the default Controller as follows:

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends Controller {

    function MY_Controller() {
        parent::Controller();
        $this->db_forum = $this->load->database('forum', TRUE);
        $this->db_app = $this->load->database('default', TRUE);
    }
}

?>

I can now use $this->db_forum->something to approach the forum db and $this->db_app->something to approach the application db. Here is where it goes wrong. I activated the profiler to see how my queries and were doing and got this:

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Nieuws::$db

Filename: libraries/Profiler.php

Line Number: 143
A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: libraries/Profiler.php

Line Number: 143

Looked it up and the library has a reference to $this->CI->db->queries. But 'db' is not in use when using multiple databases. How do I circumvent this issue? Can one be a default for example?


Messages In This Thread
2 databases and libraries - by El Forum - 01-14-2010, 08:21 AM
2 databases and libraries - by El Forum - 01-14-2010, 10:54 AM
2 databases and libraries - by El Forum - 01-15-2010, 01:36 AM
2 databases and libraries - by El Forum - 01-15-2010, 01:52 AM
2 databases and libraries - by El Forum - 01-15-2010, 02:12 AM
2 databases and libraries - by El Forum - 02-02-2010, 02:44 AM
2 databases and libraries - by El Forum - 04-26-2010, 04:30 AM
2 databases and libraries - by El Forum - 06-29-2010, 04:24 PM
2 databases and libraries - by El Forum - 06-30-2010, 12:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB