Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
That's a lot of fuss over something so insignificant. I'm curious to know if anyone has actually had a client willing to spend time and money on you actually developing that, *just* for an order number.
Jenk wrote:I'm curious to know if anyone has actually had a client willing to spend time and money on you actually developing that, *just* for an order number.
Jenk wrote:That's a lot of fuss over something so insignificant. I'm curious to know if anyone has actually had a client willing to spend time and money on you actually developing that, *just* for an order number.
Agreed, this went from a simple auto-increment value to a complex check digit algorithm and finally to algorithmic optimizations lol, but to answer your question, yes - I had a client with big pockets that wanted a simple way of validating shipping codes in the application I developed and this was how I first found about the Verhoeff algorithm, ever since then I use it on most of my ID database fields.
I didn't read everything so i'll be brief... usually, you may want to start your numbering at the number your client wishes and that number is not the ID of the column. Simply because, sometimes, order numbers may mutate into something that contains numbers and letters.
So i'd use an auto-inc for the ID of the order table, you COULD base your ORDERID column (a textual column) on your ID but then, you only need to generate your own algorithm that would generate order ids.
This method solves two problems:
1) In solutions that bill a user, you have to keep a trace of what happens... ALWAYS. I don't know of any country that states that you can play around and delete billing info.
2) Several countries force their companies to fill all of their order numbers, no number must miss, so what happens in systems that increment the seed value with or without transaction success? When you use your order table's id in a seeded auto-inc column and your transaction fails, some system will keep the increment, and you will create a gap. With a system that forces you to generate the next sequential id yourself, you can then prevent gaps of that kind...