0

I want to generate an id against a newly created user.

I want it to be something like this.

Brb-0001 after first registration.

after 10th registration it should be something like this

Brb-0010

And so on .

while searching I have come across various number generating functions but neither of these were helping me.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

This is wrong way. Use autoincrement integer field at database for this. Then you can always add Brb- prefix to this ID combined with some kind of pad left function (inside query or inside your PHP code).

Any other solutions may lead to race conditions. What if two users will register at the same time? I am pretty sure thay will have the same ID.

Evgeny
  • 3,910
  • 2
  • 20
  • 37