Hey guys was hoping you could help me out.
basically i’m working on a website created using codeigniter by someone else. The site has two instances, one for development and one for live. The site is still under construction which means files are constantly being changed and moved from the development site (after being tested) to the live site.
Now the thing is, the person who initially created the site made some database calls from a few views. And to access the database from the view, he manually connected to the database from the view, i.e using
$db=mysql_connect(...);
mysql_select_db(...);
This means that each time a view is changed, before copying the files from the dev site to the live site, we need to change the variables inside these views.
moving all queries to models, and then calling them through controllers would take too long, so was wondering if there was a way through which i could access the database variables in the database.php file and pass them as the variable for mysql_connect.
i tried $this->db->database but get the error “Undefined property: CI_Loader::$db”
thanks in advance
Define constants in constant.php assign them database username , password , host name etc and use them anywhere you want