Page 1 of 1

inserting blobs using mysqli

Posted: Wed Mar 14, 2007 6:04 pm
by TipPro
The following code works (testing with blob data < 1MB) but should I have to worry about packet size if the blob data is > 1MB?

Code: Select all

if($statement = $this->connection->prepare("INSERT INTO ".TBL_SAVED_QUOTES."(quotename, userid, timestamp, quotedata) VALUES (?, ?, ?, ?)")){
                 $null = NULL;
                 $statement->bind_param('siib', $quotename, $userid, time(), $null);
                 $statement->send_long_data(3, serialize($quotedata));
                 $savedQuote = $statement->execute();
                 $statement->close();
          }
Any advice is appreciated.

Posted: Wed Mar 14, 2007 8:46 pm
by feyd
Packet size should pretty much always be a concern.

Posted: Thu Mar 15, 2007 6:44 am
by volka
But you can call send_long_data() multiple times for the same field before invoking execute().
Get the max packet size via

Code: Select all

Show Variables LIKE 'max_allowed_packet'
and split the data accordingly.