#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    293
    Rep Power
    11

    Storing/fetching MSWord files in/from MySql: BLOB or TEXT field


    Hi.

    I need to store MS Word files in a MySql database.
    I also need to be able to download the same files from the database/server.

    The reason for this is that my client want search through the stored docs for specific words and I have no access to using the exec command in PHP on that particular server.

    I have created some testing pages: upload.php and download.php.

    The field that holds the document is called content.

    I have tested both the upload.php and download.php and it works fine.

    It actually works fine if the "content" field is defined as BLOB or if it is defined as TEXT.
    Works fine if document contains images as well, for both field-types.

    Which datatype should I use? BLOB or TEXT?
    Why should I use that datatype?

    For the time being my client only need to search the text using

    .. where content like '%search-word%' ... or ... and ....

    It might be that my client want to fulltext index the content field laiter to speed up search.

    Number of documents stored: approx 1000 to 5000.
    BongoBongo
  2. #2
  3. Rocking my php-ness
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Boston, MA
    Posts
    1,968
    Rep Power
    151
    Use whichever datatype will take up the least amount of space while still holding the entire files worth of data.
    My new WebComic http://www.jjsunshines.com/
    The Geek Shall Inherit the Earth

    It is NOT ok to IM me with questions unless I told you it was ok via PM
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Posts
    679
    Rep Power
    18
    It's one thing storing a MS Word document in a database, but another thing to search for words in it. If it's in that format, you won't be able to search for words, you can only do that with text. Well, you can search but your results will be unpredictable to say the least.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    293
    Rep Power
    11

    That sounds reasonable.


    But do you know about any pitfalls storing a MS Word document in a TEXT field, or is this totally okay.

    Do you know of any reasons for not doing that?
    Taking into account that I have to store the doc file in the db.
    BongoBongo

IMN logo majestic logo threadwatch logo seochat tools logo