PHP - uniqid(“”,true) versus uniqid(“”)+mt_rand()

前端 未结 2 934
陌清茗
陌清茗 2021-01-26 21:52

What are the key differences between these two approaches to generate sequential-but-somewhat-unique numbers? I want to use such a number as a unique user ID inside a MySQL db,

2条回答
  •  清酒与你
    2021-01-26 22:19

    (scratch this, wrong info, sorry)

    So yes, as Gumbo pointed out, it's not a hash but indeed a microsecond resolution increasing timer value, optionally concatenated with a random number. So, the values are still not sequential, but at least steady. The difference between the two approaches would then be very small.

    This one still holds: If you need unique sequential numbers, and you use MySQL, use an auto increment field, they do just that.

提交回复
热议问题