On Thu, Feb 22, 2001 at 05:23:00PM -0800, Bob Crandell wrote:
> Hi,
> I'm using Apache/PHP/MySQL to learn SQL.  Besides dazzling
> people with my prowess, I'd like to be able to store digital
> pictures in the database.  So far, I've gotten to the chapter
> that creates a form to type in a product code, description and
> price.  Yawn.
> Does anyone know the SQL code to insert a binary file into a
> MySQL database?  What type of field does it take?  I didn't see
> mention of a blob.  Maybe that's the next book.
> 
> Thanks

Try "MySQL" by Paul DuBois, New Riders Publishing.
(there is no next after this, IMHO)

CREATE TABLE my_images (
  image_id SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
  image_data BLOB
);

sizes in bytes
TINYBLOB        2^8 - 1
BLOB            2^16 - 1
MEDIUMBLOB      2^24 - 1
LONGBLOB        2^32 - 1


Keep in mind the default query buffer is 100k

I've never done this, and the book doesn't have a PHP example
of using BLOBs.  There is a C function on page 269 though.
There are also some warnings of fragmentation.

<[EMAIL PROTECTED]>

Reply via email to