inserting blobs using mysqli

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
TipPro
Forum Commoner
Posts: 35
Joined: Wed Mar 15, 2006 6:39 pm

inserting blobs using mysqli

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Packet size should pretty much always be a concern.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Post Reply