title: codeigniter database calls from view
body: <p>Hey guys was hoping you could help me out.</p>
  
  <p>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.</p>
  
  <p>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</p>
  
  <pre><code>$db=mysql_connect(...);
  mysql_select_db(...);
  </code></pre>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>i tried $this->db->database but get the error "Undefined property: CI_Loader::$db"</p>
  
  <p>thanks in advance</p>