Welcome Guest, Not a member yet? Register   Sign In
Can't select database using extended controller. regular controller works.
#19

[eluser]CroNiX[/eluser]
You should be able to define them like that in the constructor, and then use $this->DB1 and $this->DB2 to access them from your methods.

Although, I don't think you need to load this one assuming you are already loading your default database:
Code:
$DB1 = $this->load->database('default', TRUE);
If you are just use $this->db like normal to use your default. You only need to define the 2nd connection.

Code:
class Something extends Something_else {

  public $db_wo;

  function __construct()
  {
    parent::__construct();

    //Create the 2nd db connection
    $this->db_wo = $this->load->database('wo', TRUE);
  }

  function sample()
  {
    //Access default db
    $data = $this->db->select(...)->get(...)->result();

    //Access wo db
    $wo_data = $this->db_wo->select(...)->get(...)->result();
  }
}
Does that work for you?


Messages In This Thread
Can't select database using extended controller. regular controller works. - by El Forum - 05-22-2012, 08:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB