Large insert queries
| From: | Timo Haimi | Date: | Mon, 02 Oct 2000 05:13:59 +0000 |
| Subject: | Large insert queries | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18242@lists.php.net to get a copy of this message | ||
Hi,
I've got a problem while inserting a large blob to database. When the
filesize is over 1 MB, the mysql server says it's gone away..
The code is more or less like this;
$fp=fopen("datafile","r");
$data=fread($fp,filesize("datafile"));
fclose($fp);
$data=str_replace("'","''",$data);
$data=str_replace("\\","\\\\",$data);
$sql="insert into data(id,data) values (1,'$data')";
mysql_query($sql);
The code works with, lets say, 900Kb files but when we go over megabyte the
server dies. Does it take too long to write the insert clause to server or
something like that? If this is the case, how to make it faster?
-Timo