Welcome Guest, Not a member yet? Register   Sign In
multiple databases connectivity
#2

(This post was last modified: 10-13-2017, 04:12 PM by dave friend.)

To make the alternate database available to multiple models make the property $anotherDb a member of the controller. Set the property in the controller's constructor.

PHP Code:
Class Welcome extends CI_Controller
{
   public $anotherDb;

   function __construct()
   {
       parent::__construct();
       $db_name $this->session->db_name;
       if(isset($db_name))
       {
            $this->anotherDb $this->load->database($db_nameTRUE);
        }
        else
        {
              throw new Exception('Second database name not found.');
         }
   
Reply


Messages In This Thread
multiple databases connectivity - by nadeem14375 - 10-12-2017, 07:13 PM
RE: multiple databases connectivity - by dave friend - 10-13-2017, 04:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB