Forum Moderators: coopster & phranque

Message Too Old, No Replies

Search in Blob Field in Mysql

         

pavelcz

8:00 pm on Nov 6, 2002 (gmt 0)

10+ Year Member



Is any possibility to do searching in a txt file by using PHP, what has been stored in BLOB (binary) MySQL field?
Many thanks, Pavel

jatar_k

8:12 pm on Nov 6, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com] pavelcz,

I really have no idea, I only use blobs for fields that will be displayed only, not searched or sorted. Have you looked through mysql.com for any information? Sounds like it could be rather server intensive. A "LIKE" clause is the only thing that comes to mind.

pavelcz

8:46 pm on Nov 6, 2002 (gmt 0)

10+ Year Member



jatar_k,

Many thanks for your reply. I tried to find information about searching in BLOB on the net but wihout any success. But thanks to finding the info I found your forum which seems to to be very useful...

Pavel

andreasfriedrich

11:39 pm on Nov 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look at MySQL´s Full-text Search [mysql.com] feature.

Andreas

seindal

11:53 pm on Nov 6, 2002 (gmt 0)

10+ Year Member



Hi Pavel,

>Is any possibility to do searching in a txt file
> by using PHP, what has been stored in BLOB
> (binary) MySQL field?

First, if the content is text as you state, perhaps you should use a 'text' field, not a 'blob'. Searches on a 'text' field is case-insensitive, on a 'blob' it is case-sensitive.

You can use a fulltext index as mentioned, but only with the MyIsam table type. If you use BDB or InnoDB tables to get transaction support, there is no support for fulltext indexes.

With fulltext indexes your searchwords are ranked by MySQL, words of three letters or less are silently ignored, and words that matches more than half the records are automatically stop-words.

If a fulltext index is nor possible or useful for your problem, you have to fall back to using the LIKE operator, eg, ... WHERE text_field LIKE "%word%"

You can search on anything, not just words like with fulltext indexes, but you have to implement multiwords searches youself by combining several conditions.

LIKE is probably going to be slower that fulltext searches if you have many records.

René.

jatar_k

12:00 am on Nov 7, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com] seindal