title: Is it possible to run a long .sql file through Codeigniter?
body: <p>I want to run a <code>.sql</code> file from my server in Codeigniter 3.1.0. I have tried following</p>
  
  <pre><code>//code to create a DB &amp; this is successful then following ocde 
  $query = file_get_contents('./test.sql');
  $this-&gt;db-&gt;query($query);
  </code></pre>
  
  <p>Here is my <code>test.sql</code> file. <a href="https://gist.github.com/rejoan/97dfae1b08116e386b3e6fda97eeb4f7" rel="nofollow">https://gist.github.com/rejoan/97dfae1b08116e386b3e6fda97eeb4f7</a></p>
  
  <p>Now when I run this it shows error always</p>
  
  <blockquote>
    <p>A Database Error Occurred</p>
    
    <p>Error Number: 1064</p>
    
    <p>You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near 'CREATE TABLE <code>user</code> ( <code>id</code> int(11) NOT NULL, <code>test_id</code> int(11)
    NOT NULL, `' at line 10</p>
  </blockquote>
  
  <pre><code>CREATE TABLE `test` 
  ( `id` int(11) NOT NULL, 
  `name` varchar(250) NOT NULL, 
  `description` text NOT NULL, 
  `added` date NOT NULL, 
  `outdate` date NOT NULL 
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
  
  CREATE TABLE `user` 
  ( `id` int(11) NOT NULL, 
  `test_id` int(11) NOT NULL, 
  `name` varchar(250) NOT NULL 
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
  
  ALTER TABLE `test` ADD PRIMARY KEY (`id`), 
  ADD UNIQUE KEY `name` (`name`);
  
  ALTER TABLE `user` ADD PRIMARY KEY (`id`), 
  ADD KEY `test_id` (`test_id`); 
  
  ALTER TABLE `test` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=37; 
  
  ALTER TABLE `user` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 
  
  ALTER TABLE `user` 
  ADD CONSTRAINT `FK_user_test` FOREIGN KEY (`test_id`) 
  REFERENCES `test` (`id`) ON UPDATE NO ACTION;
  </code></pre>
  
  <blockquote>
    <p>Filename: C:/xampp/htdocs/spider_clients/system/database/DB_driver.php</p>
    
    <p>Line Number: 691</p>
  </blockquote>
  
  <p>So how can I resolve this by issue? I have a idea to do this by PHP raw code but Firstly I want to solve by CI. Any Idea?</p>
  
  <p>** Even I have tried by replacing all backtick by single quote still not works</p>