AboutRobert Davis Expertise My focus in PHP has been calculations, reporting, database manipulation (MySQL), automated scripting, screen scraping, and tracking systems. A more complete summary is posted at http://businesscatalyst.info.
Experience I've been programming in many languages for over 13 years, but the last couple years I've focused on php. I've posted several tricks I've learned at goodfeelingplace.com.
Education/Credentials I have a bachelors degree and a masters degree, both in electrical engineering from Arizona State University.
Question QUESTION: Hi Robert,i'm creating the store from scratch with codeigniter..Are there any disadvantage with using autoincrement index?I've been thinking about creating a table that holds the number using varchar instead of int,i get the number from the table then i update it again if there are a transactions..But in another way,i've been thinking does it consume resources as i have to convert the string to int first and then convert it again.What is your suggestion?Thanks a lot and God bless you. ^_^
ANSWER: Hi Handoyo,
If you are doing it from scratch I would definitely recommend an autoincremented ID as the invoice number, as you know it will be unique and it is light on resources. The only reasons I would do it another way is if you wanted to make the invoice number mean something, by including other info in it like customer ID/code, date, etc. - or if you needed it to be random or encoded for some reason.
Regards,
Robert
---------- FOLLOW-UP ----------
QUESTION: Suppose i want to include other info,what is the best way to define the fields?Thanks a lot..
Answer If the characters will all be numbers then I would create an integer field, if not I would define it as a varchar field (assuming it's mysql) and set the size to the max amount of characters I expect in that field. Then I would define the values (by including whatever info you want) in php before entering the value in the db.