I'm querying a remote mysql database and retieving a large number of records (600K records with about 12 columns for each record) which I am then writing out to a file on the local machine. I'm having problems with the process timing out, I only get about half of the records, and I'm wondering if there is a better solution then the one I'm using? Either inncreasing the timeout, or better yet by optimizing my code? Mysqldump is not an option for me at this point.
$handle=fopen($filename, 'w+');
//the query
$result = mysql_query("SELECT 1,2,3,4,5 FROM product");
while($row = mysql_fetch_array($result)) {
//write out the results to a file
fwrite($handle, "$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\n");
}
fclose($handle);
Thanks in advance.