h_h
h_h

Reputation: 1231

Codeigniter connecting to multiple databases

I have been using these lines of code for connecting multiple databases in codeigniter but getting error. My new db connection is for new_group.

$this->new_group = $this->CI->load->database('new_group', TRUE); 
$q = $this->new_group->query("SELECT* FROM mytable ORDER BY id DESC");

Call to a member function database() on a non-object.

Waiting for response. Thanks

Upvotes: 0

Views: 401

Answers (2)

Laurence
Laurence

Reputation: 60068

remove ->CI from the load command

$this->new_group = $this->load->database('new_group', TRUE); 
$q = $this->new_group->query("SELECT* FROM mytable ORDER BY id DESC");

or you have to load the CI object first:

$this->CI =& get_instance();
$this->new_group = $this->CI->load->database('new_group', TRUE); 
$q = $this->new_group->query("SELECT* FROM mytable ORDER BY id DESC");

Upvotes: 2

Djomla
Djomla

Reputation: 616

Try this http://codeigniter.com/forums/viewthread/145901/

$db['new_group']['pconnect'] = FALSE;

I didnt try...

Upvotes: 2

Related Questions