[Database class] Generating order numbers
Paul S. Wang
pwang at cs.kent.edu
Wed Mar 7 13:22:13 EST 2012
Tyler,
Good question. I guess I am the one to explain it even though
you have never gotten an order in real life that is a sequence number,
right?
Here goes:
A merchant usually require an order number to do customer service
such as returns, refunds, and issuing a duplicate receipt etc.
If a customer can guess at the order number, they could potentially
get information on orders not belonging to them.
Another thing is, we may have different kinds of orders such as
those sold in one store vs. another, so often order numbers will
have coded in them such info.
Paul
On Wed, Mar 07, 2012 at 12:46:43PM -0500, Tyler Herzog wrote:
> Date: Wed, 7 Mar 2012 12:46:43 -0500
> From: Tyler Herzog <therzog at kent.edu>
> To: pwang at cs.kent.edu
> Subject: Re: [Database class] Generating order numbers
> X-Mailer: Apple Mail (2.1257)
>
> Prof. Wang,
>
> Just out of curiosity, what's the benefit of choosing a randomly generated order number and checking against duplicates, vs going in order numerically? Meaning, just choosing the next higher digit for a new order?
>
> Tyler Herzog
> therzog at kent.edu
>
>
> On Mar 7, 2012, at 12:44 PM, Paul S. Wang wrote:
>
> > Dear DB class,
> >
> > There was a question of generating order numbers. Of course
> > writing a function for that in your particular application context
> > would be the answer. Here is an example:
> > <?php ///// genOrd.php /////
> > function genOrd()
> > { $prefix="ord_";
> > if ( function_exists("date_default_timezone_set") )
> > date_default_timezone_set('US/Eastern');
> > $dt=date("Md");
> > $r=rand(10000000, 99999999);
> > return "$prefix".$dt."_".$r;
> > }
> >
> > echo genOrd();
> > ?>
> >
> > Also, when a new order is entered into the orders table,
> > a duplicate order number would cause an error. So that needs to
> > be checked as always with any query.
> >
> > Paul
> >
> > --
> > ==============================================================================
> > Paul S. Wang (王士弘) Email: pwang at cs.kent.edu
> > Dept. of Computer Science, Kent State U. Tel: (330) 672-9051
> > Kent, Ohio, USA 44242-0001 http://www.cs.kent.edu/~pwang/
> > ==============================================================================
> > _______________________________________________
> > Dbclass mailing list
> > Dbclass at listmail.cs.kent.edu
> > https://listmail.cs.kent.edu/mailman/listinfo/dbclass
>
--
==============================================================================
Paul S. Wang (王士弘) Email: pwang at cs.kent.edu
Dept. of Computer Science, Kent State U. Tel: (330) 672-9051
Kent, Ohio, USA 44242-0001 http://www.cs.kent.edu/~pwang/
==============================================================================
More information about the Dbclass
mailing list