Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6311

Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column?

From "Peter H. Coffin" <hellsop@ninehells.com>
Newsgroups comp.lang.php
Subject Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column?
Date 2012-06-12 14:26 -0500
Organization A noiseless patient Spider
Message-ID <slrnjtf5vi.h39.hellsop@nibelheim.ninehells.com> (permalink)
References <b3a88b31-765b-4537-adfd-563c4734c66a@googlegroups.com> <jr627b$aqj$1@dont-email.me> <a3acc71e-a388-47ed-97c5-72f4d04c40e5@googlegroups.com>

Show all headers | View raw


On Tue, 12 Jun 2012 11:47:04 -0700 (PDT), kurtk@pobox.com wrote:
>> No, hashes can never guaranteed to be unique.
>
> I opted to use
>
>   md5(uniqid()); 
>
> to create a unique key.

Still not guaranteed to be unique. You've even got a defined 13-hexdigit
space thing what you're hashing. Which means as soon as you've got more
than 4,503,599,627,370,495 entries, you are GUARANTEED a collision. That
seems like a lot, but you're down to a one in a billion shot at a
collision when you've got a few million entries. And everybody knows,
that one in a billion changes turn up nine times in ten.

-- 
48. I will treat any beast which I control through magic or technology
    with respect and kindness. Thus if the control is ever broken, it 
    will not immediately come after me for revenge.
	--Peter Anspach's list of things to do as an Evil Overlord

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column? "kurtk@pobox.com" <kurtk@pobox.com> - 2012-06-11 17:16 -0700
  Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column? Jerry Stuckle <jstucklex@attglobal.net> - 2012-06-11 20:24 -0400
    Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column? "kurtk@pobox.com" <kurtk@pobox.com> - 2012-06-12 11:47 -0700
      Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column? Jerry Stuckle <jstucklex@attglobal.net> - 2012-06-12 15:06 -0400
      Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column? "Peter H. Coffin" <hellsop@ninehells.com> - 2012-06-12 14:26 -0500
        Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column? Jerry Stuckle <jstucklex@attglobal.net> - 2012-06-12 19:34 -0400
      Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column? Captain Paralytic <paul_lautman@yahoo.com> - 2012-06-13 04:09 -0700
        Re: Is spl_object_hash unique in the SQL sense? Can it be used as a   unique SQL db column? Goran <goran@nospam.com> - 2012-06-13 13:40 +0200
          Re: Is spl_object_hash unique in the SQL sense? Can it be used as a unique SQL db column? Captain Paralytic <paul_lautman@yahoo.com> - 2012-06-19 03:32 -0700

csiph-web