I am trying to edit my config/database.php within my CodeIgniter project so that I don't have to keep changing the database information every time I push a new version to the server. To do the latter, I have created a $debug variable, shown below, which checks against the uri to see if the site is being run on my localhost machine (where I build the project before upload) or on the actual server.
Unfortunately in the database.php file, I don't have access to the $this variable, and as I am personally new to OOP in PHP, I am not entirely sure of a way around this. Please can you tell me how I can do so?
Thanks,
Max.
Fatal error: Using $this when not in object context in application/config/database.php on line 51
$debug = strpos($this->uri->config->item('base_url'), 'localhost'); //line 51
$db['default']['hostname'] = $debug == TRUE ? 'x' : 'y';
$db['default']['username'] = $debug == TRUE ? 'x' : 'y';
$db['default']['password'] = $debug == TRUE ? 'x' : 'y';
$db['default']['database'] = $debug == TRUE ? 'x' : 'y';