I have an iPad application that suppose to be able to work offline. I got a local database(sqlite) that stored all the data needed. When i want to update the database, i create my query from the server side (PHP server), make it as a sql file, download to the app, and tried to read the sql file. Below is the sample code
$txt = "CREATE TABLE IF NOT EXISTS `UOM` (`uom_id` int(11), `uom_name` varchar(200), `uom_status` int(11));";
$txt .= "INSERT INTO `UOM` (`uom_id`, `uom_name`, `uom_status`) VALUES (1, 'Unit', 1);";
$txt .= "INSERT INTO `UOM` (`uom_id`, `uom_name`, `uom_status`) VALUES (2, 'Kg', 1);";
$txt .= "INSERT INTO `UOM` (`uom_id`, `uom_name`, `uom_status`) VALUES (3, 'Liter', 1);";
$myfile = fopen("queries_" . $timeStamp . ".sql", "w");
fwrite($myfile, $txt);
fclose($myfile);
My question is, how can i import it into my local database ?i cannot open the sql file and read the query line by line since the file is too large(my database contain more than 40k of records), when I try to read it line by line (inside a loop) the app crash due to memory problem (very tight loop). I would like to know is there any way to execute this sql file on my local database without reading the file ?something like import this sql file to my local database programatically.
Thanks.