General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Minimize the cost of deploying database applications. Advantage Database Server or Microsoft SQL Server – Which One is Right for You? Learn now!
  #1  
Old June 16th, 2002, 06:47 AM
kadnan kadnan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Pakistan
Posts: 1 kadnan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Comparing Binary Data

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

Reply With Quote
  #2  
Old June 16th, 2002, 05:57 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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

Reply With Quote
  #3  
Old June 17th, 2002, 03:08 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 6
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Lightbulb

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...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Comparing Binary Data


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway