I have that script that downloads all the contents of my table in sql format and save a local copy. My problem is the content of my table is so huge, the actual data is about 50MB and the data being generated of my script is just 3.5MB. What's wrong with my script? why all data are not written in sql file?
$table = "Downloads";
$result = $db->query('SELECT * FROM '.$table);
$num_fields = $db->num_fields($result);
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
{
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
//save file
$handle = fopen(UPLOAD_XML_PATH_ABSOLUTE.'downloads_backup'.'.sql','w+');
if(fwrite($handle,$return)){
fclose($handle);
//$ret = true;
} else {
//$ret = false;
}