Reputation: 674
I need to connect to a DB that's name will be entered in the URL. For Example the URL will be
http://my_url.com/comp/login
So the DB I need to connect to is 'comp'.
Is there a way to do this without defining each database in the database.php config file?
something like
define('COMP', $this -> uri -> segment(1));
and then
'database' => 'tm_'.COMP,
The above gives me an error about the $this, so I am not completely sure where I can define the COMP variable where the database config file can read it.
Thanx
Upvotes: 0
Views: 178
Reputation: 674
Was missing this part :
$CI =& get_instance();
and updated the
define('COMP', $this -> uri -> segment(1));
to
define('COMP', $CI -> uri -> segment(1));
is working now
Upvotes: 1