Jump to content

Creating order ID's


Eiolon

Recommended Posts

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!
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.