I am having major problems doing a blob insert.
Seems that MySQL on my server is set up so the max_allowed_packet is 1M. I am on a shared server (cant change mysql settings) so i tried to work aroudn this by doing the following: (basically moving teh pointer down the file and inserting in segments)
$filehandle = fopen($addfile, "r");
$filesize = filesize($addfile);
$buffer = addslashes(fread($filehandle, 90000));
$query = "Insert into files (file,filename, size, userid ) values ('$buffer','$addfile_name', '$filesize')";
$this->query($query);
$id = mysql_insert_id($this->link_id());
while (!feof ($filehandle)) {
$buffer = addslashes(fread($filehandle, 90000));
$query = "UPDATE files SET file = concat(file,'$buffer') where id='$id'";
$this->query($query);
}
fclose ($filehandle);
But concat i guess is only for string fields, and not for blob fields. I have tried functions like LOAD_DATA('path/to/tmp/dir').
Does anyone know a workaround for this, this shared server @!#$ is starting to piss me the f**** off. Thanks in advance.
- FYI - for those who want to know how to change packet size etc:
/usr/local/bin/safe_mysqld -O key_buffer=16M -O table_cache=128 -O sort_buffer=4M -O record_buffer=1M -O max_allowed_packet=24M