|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Minimize the cost of deploying database applications. Advantage Database Server or Microsoft SQL Server – Which One is Right for You? Learn now! |
|
#1
|
|||
|
|||
|
HEllo Mitchell
I read your article regarding Images storage in Mysql,i want to know the way that i cant store an image more than once,how can i compare binary data(being uploaded)with Binary data ,present in mysql Database Regards Adnan |
|
#2
|
|||
|
|||
|
Hmmm, well that would be a time consuming process, because as I'm sure you know, binary data is large in size and comparisons would be slow. Basically you would just read the binary data from an image file and then use the = operator to compare with the database.
For example, if $theImage contained binary data read in from a file, and you have a MySQL table like this: images __________ id int image blob then you would use $result = mysql_query("select image from images"); while($row = mysql_fetch_row($result)) { if($row[0] == $theImage) // They are the same, do something here } You would need to use addslashes when reading in from the file. Checkout my PHP+MySQL blob tutorial at http://www.devarticles.com/art/1/68 for a more detailed explanation ![]() |
|
#3
|
|||
|
|||
|
This is just a quick thought... but if I knew I would be comparing binary data to find differences, I would group binary data in the tables by adding some sort of flag to that record to designate something like maybe file size or type.
If I were doing it on size, I would group them something like this: group1 = .5mb-1mb group2 = table: bin_group group_name | description group1 0mb-.99mb group2 1mb-1.99mb group3 2mb-2.99mb etc... Now, when I compare, I can disassociate more quickly and do a comparison by a smaller number of files. Now I can compare 1mb files to 1mb files. Now if most of the files are very similar in size and there are lots of them, the groups just need to be broken down further. If someone implements this, I'd be happy to hear how it turns out... as a matter of fact, I may end up trying it out myself and posting a tutorial on it. Later... |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Comparing Binary Data |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|