Re: Manipulating Blob Fields
| From: | OKi98 | Date: | Thu, 14 Feb 2008 11:25:12 +0000 |
| Subject: | Re: Manipulating Blob Fields | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-44602@lists.php.net to get a copy of this message | ||
-------- Original Message --------
Subject: Re: [PHP-DB] Manipulating Blob Fields
From: julian <correojulian33-php@yahoo.es>
To: php-db@lists.php.net
Date: 14.2.2008 11:24
After some research I found a workaround, not a solution. Diggin in www.php.net I found the following (potential) bug apparently resolved time ago http://bugs.php.net/bug.php?id=35155 in relation toThe code looked like this: $buffer = ''; $buffer_length = 0; $max_packet_size = 750000; for ($i = 0; $i < sizeof($inserts); $i++) { $current_values = '(' . $inserts[$i]['col1'] . ', ' . $inserts[$i]['col2'] . ', ' . $inserts[$i]['col3'] . ')'; if (($buffer_length + strlen($current_values)) > $max_packet_size) {Bug #35155 prepared statement with blob field does not workWhich is exactly what it is happening to me. It refers to the use a function mysqli_stmt_send_long_data. Apparently you only need to use this function if your data is larger than max_allowed_packet, which in my system is 16MB. The fact is, it is the only way I have managed to store pdfs files in the field. My pdf files a very small < 5Kb. Happy to have it working, but hesitant to understand why.... Regards. JCG I had similar problem. I needed to insert few thousands of rows.
if (!mysql_query($buffer, $connection))
{
// error handling
}
$buffer = '';
$buffer_length = 0;
}
$buffer .= ($buffer != '') ? ", $current_values" : "INSERT INTO table (col1, col2, col3) VALUES $values";
$buffer_length += strlen($current_values);
}
It was interesting that although MySQL's internal max_packet_size was more than 1 MB I was able to send only about 100kb long query. I have never figured out why does this happen