I want to run a .sql file from my server in Codeigniter 3.1.0. I have tried following
//code to create a DB & this is successful then following ocde 
$query = file_get_contents('./test.sql');
$this->db->query($query);
Here is my test.sql file. https://gist.github.com/rejoan/97dfae1b08116e386b3e6fda97eeb4f7
Now when I run this it shows error always
A Database Error Occurred
Error Number: 1064
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
user(idint(11) NOT NULL,test_idint(11) NOT NULL, `' at line 10
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;
Filename: C:/xampp/htdocs/spider_clients/system/database/DB_driver.php
Line Number: 691
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?
** Even I have tried by replacing all backtick by single quote still not works
 
     
     
    