title: how to grab database name form config in codeigniter and run a sql file to insert tables into database?
body: <p>I Want to grab a <code>database</code> name from <code>config/database.php</code>. 
  I have written this <code>code</code>. but it not works.</p>
  
  <pre><code>$dbname = $_POST['dbname'];    
  $db =  $this-&gt;db-&gt;database;
         if($dbname == $db)
            {
              $template = 'application/views/install/db/dbwrite.sql'; 
              $template_path =  set_realpath($template);
              $result = $this-&gt;db-&gt;query(file_get_contents($template_path)); 
            }
      $this-&gt;load-&gt;view('login');
  </code></pre>
  
  <p>After this when I select the <code>database</code> name then I want to execute this SQL file <code>dbwrite.sql</code> to create a table in the database automatically.</p>
  
  <p>dbwrite.sql </p>
  
  <pre><code>CREATE TABLE Persons (
      PersonID int,
      LastName varchar(255),
      FirstName varchar(255),
      Address varchar(255),
      City varchar(255) 
  );
  </code></pre>