Re: Some kind of checksum
| From: | Mike Eheler | Date: | Mon, 15 Oct 2001 18:10:08 +0000 |
| Subject: | Re: Some kind of checksum | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71125@lists.php.net to get a copy of this message | ||
md5 :)
"SELECT * FROM table WHERE MD5(blob_field) = '" . md5($filecontents) .
"'"
Or even less strenuous on the server, alter the DB so it has a
varchar(32) field, call it 'md5sum' or something:
"SELECT * FROM table WHERE md5sum = '" . md5($filecontents) . "'"
Which would have been created by doing:
"INSERT INTO table (blob_field,md5sum) VALUES ('$filecontents','" .
md5($filecontents) . "')"
Mike
Boget, Chris wrote:
>I'm using MySQL and that is the context with which I write
>this email.
>
>I have a buch of text files that I want to add to a database so
>we can add all kinds of search functionality for those files.
>Each would be stored in either a TEXT or BLOB field. These
>files can have all kinds of special characters ( ", ', etc) so it
>would be necessary that I use addslashes().
>
>What I would like to do is make it so that I can check to see if
>the file has already been added to the database. I'm having a
>problem where if the text is too large, I can't query to see if the
>contents of the current file equals the contents of the field I'm
>storing it in. Is there any way that I can do some kind of
>checksum on both the contents of the file and the contents of
>the field to determine if that file has already been added? I'm
>trying to make it so that I don't have duplicate files in the DB.
>Has anyone done something like this?
>
>Chris
>