codeigniter-base-model icon indicating copy to clipboard operation
codeigniter-base-model copied to clipboard

Specify a database connection on a per-model basis by declaring instance variable

Open webquail opened this issue 10 years ago • 0 comments
trafficstars

The class will automatically use the default database connection, and even load it for you if you haven't yet.

You can specify a database connection on a per-model basis by declaring the _$database instance variable. This is equivalent to calling $this->db->database($this->_database, TRUE).

class Post_model extends MY_Model
{
    public $_database = 'group_name';
}

webquail avatar Jul 08 '15 10:07 webquail