• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple databases

#1
[eluser]ray73864[/eluser]
Hi, i know this has been asked a few times but i can't seem to find the correct answer to resolve this problem.

In my 'database.php' config file i have removed the 'default' group and changed '$active_group' to be nothing, i then set up 2 new groups (1 called web and the other email) and set the appropriate username/password/database up on them.

then in the constructors of my 2 controllers 'web' and 'email', i have done: $web = $this->load->database('web',TRUE) and $email = $this->load->database('email',TRUE);

I then did a simple query in my email controller such as '$query = $email->query("SELECT * FROM domains");' and then 'print_r($query->result_array());'

However when i run the controller it comes back with:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Email::$email

Filename: controllers/email.php

Line Number: 16

Line 16 is the '$query' statement.

Also, when i try to run the scaffolder, it comes back with:

An Error Was Encountered

You have specified an invalid database connection group.

#2
[eluser]ray73864[/eluser]
ahha, i changed the constructor statement so that it became: $this->email = $this->load->database('email',TRUE);

and then changed the query i am doing to $this->email->query() and it all worked good (the multiple databases userguide at 'http://ellislab.com/codeigniter/user-guide/database/connecting.html' didn't mention that.

Is there anyway i can get the scaffolder to use the newly loaded database connection, or will it only look at 'active_group'?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.