Welcome Guest, Not a member yet? Register   Sign In
How to create random, but unique IDs?
#9

[eluser]n0xie[/eluser]
There isn't really much you can do about scrapers, no matter how you build your URL. As for the age of the items, I guess you have a point. I just think you're making it way more complicated than need be. You could probably throw a rand function together that 'randomly' picks a number between 1 and 10.000.000, then match it against the db to see if it already exists. The maximum int size on a 32bit system is 2.147.483.647 which should be big enough for what you need:
Code:
function get_random_id()
{
  $id = mt_rand(1,mt_getrandmax());
  $query = $this->db->where('some_id',$id)->limit(1)->get('some_table');
  if ($query->num_rows() > 0)
  {
    return $this->get_random_id();
  }
  else
  {
  return $id;
}


Messages In This Thread
How to create random, but unique IDs? - by El Forum - 05-12-2010, 12:14 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 12:34 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 01:10 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 01:14 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 01:34 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 01:38 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 01:55 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 01:59 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 02:24 PM
How to create random, but unique IDs? - by El Forum - 05-12-2010, 02:53 PM
How to create random, but unique IDs? - by El Forum - 05-13-2010, 06:49 AM
How to create random, but unique IDs? - by El Forum - 05-13-2010, 01:26 PM
How to create random, but unique IDs? - by El Forum - 05-13-2010, 01:51 PM
How to create random, but unique IDs? - by El Forum - 05-13-2010, 02:45 PM
How to create random, but unique IDs? - by El Forum - 05-13-2010, 07:03 PM
How to create random, but unique IDs? - by El Forum - 05-14-2010, 12:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB