I’m developing an e-cart/shop with PHP/MySQL.
I had decided from the beginning to have a separate table for addresses so that I would not store duplicate data (for example, every time an order is made to the same address, the order would store the address_id rather than door, street, town, city, post_code, etc.
Now I’m making the query to process an Order, I’m going to have an option for the user to
a) select an address from a stored list (of customer_id, address_id) -or-
b) create a new address (the query returns the lastInsertId() ).
I’m having doubts because I’m not sure if there are any situations where the lastInsertId() would return the wrong address_id and so the system would send the order to the wrong, stored address? Or when the order is processed a wrong id number is passed through?
What extra steps can I take to make such a system fool-proof so that the wrong address is never given?
See more: http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html