I am developing a simple billing system using PHP and MySQL.
My initial thought was to use an identifier (auto incremented) for an account identifier. But that will not work.
A temporary invoice is created when the user places an order with my payment service provider. If the transaction failed, I need to delete the temporary invoice.
The problem is that the invoice was created and provided, and the identifier - and by law, I canβt delete any invoices that have been assigned an invoice number. So I need to add another column "invoice_id" and add an identifier after a successful transaction.
Several users can make a purchase at the same time.
My question is: how can I get the last created account identifier and increase it?
Should I use $_SESSION[]for storage invoice_id? Or do I need to get the last identifier from the database? If you are retrieving from a DB, should I lock the table for this transaction?
Any recommendations that are much appreciated.
source
share