Re: Manipulating Blob Fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-------- Original Message  --------
Subject: Re:  Manipulating Blob Fields
From: julian <correojulian33-php@xxxxxxxx>
To: php-db@xxxxxxxxxxxxx
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 to

Bug #35155      prepared statement with blob field does not work

Which 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.
The 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)
   {
       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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux