mysql - Using php mt_rand() function -


am trying use php mt_rand() function produce me unique number used unique identifier row in database. can pick number had picked range 1, 1000000. code follows echo mt_rand(1, 1000000);?> continued help

yes, produce duplicates. it's random, not unique. easiest solution use auto-increment column. if don't want sequential, have couple options. these 2 @ first:

https://github.com/ramsey/uuid

http://php.net/manual/en/function.uniqid.php


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -