Eiolon Posted January 20, 2007 Share Posted January 20, 2007 I am not sure if this is something that is handled on the database side or from PHP.Basically, if I order something online I am given an order ID that consists of many letters and/or numbers (i.e. #1000001)I am wanting to do something similar. I have a field called order_id but that is the record ID which I don't think is a good thing to have exposed. So I am wanting to know a good way to implement something like this. Any suggestions? Thanks! Quote Link to comment Share on other sites More sharing options...
printf Posted January 20, 2007 Share Posted January 20, 2007 If you don't want to use the unique auto_increment column, then you can create a column called 'whatever', then insert something like...[code]ALTER TABLE your_table ADD order_hash CHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER some_column;ALTER TABLE your_table ADD INDEX ( order_hash ) ;[/code]Where as...your_table = would be changed to your table name!order_hash = would be changed to the name you want the new column to be named as!some_column = would be changed to the column name you want the new (order_hash) column to be inserted after.Then when you create a new order to insert into your order table you could create a hash like so![code]$insert_order_id = md5 ( uniqid ( microtime () ) );[/code]printf Quote Link to comment Share on other sites More sharing options...
fenway Posted January 22, 2007 Share Posted January 22, 2007 A unique index would also probably be in order. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.