Good day,

This isn't really on the topic of PHP.

But, to answer your question- yes, MySQL will let you do lots of neat things
with those large text fields, like looking for substrings and such.  If you
want to store some text information, even that which might have special
characters, line feeds and so forth, the "TEXT" field is definately the way
to go.

Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948

-----Original Message-----
From: Erik Price [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 07, 2002 4:10 PM
To: gregory hernandez
Subject: Re: [PHP] php, text file, and mysql

On Thursday, March 7, 2002, at 07:16  PM, gregory hernandez wrote:

> can i insert the actual file (i.e. "document.txt", of course with it
> contents) into a mysql?
> in other words, i don't want to read the contents of the file and 
> insert the
> contents into a field in mysql.  i want to insert the actual file into 
> the
> database.  is this possible?

Yes you can, though it might be an inefficient way of doing it unless 
you have some reason to do it this way.  Look into the column type 
"BLOB" (binary large object), it lets you store binary large objects, 
such as images or files or anything, really.

Why inefficient?  Well, for one thing, BLOBs don't retrieve as quickly 
as regular fields, for reasons I don't altogether know.  Also, you won't 
be able to form a query to search for any characteristics of a BLOB, 
since MySQL will treat the BLOB as a BLOB and doesn't try to imagine 
what's inside it -- as opposed to, say, a VARCHAR column.  There is also 
a TEXT column type for very long text strings, and I forget whether or 
not the contents of these can be used in queries -- can someone please 
confirm this?  But basically, almost any other column type is valid 
subject matter for forming queries.

But for storing images and PDFs or other binary data, there's no other 

Note that many MySQL wizards will recommend that instead of storing 
binary data in a database, use a filesystem to store the data and then 
use the database to create a sort of "directory" for quickly locating 
those files in the filesystem, remembering the path to the file or 
something.  I think this is how a lot of web sites incorporate graphic 
content in with their database (text) content (including mine).



Erik Price
Web Developer Temp
Media Lab, H.H. Brown

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to