Unique Order ID"s high volume site HELP

Unique Order ID"s high volume site HELP

am 17.12.2004 02:22:29 von Eric Haskins

Hello all,

I am built a frontend for a system that talks to a Credit gateway. I
have run into a problem generating Unique Order ID's

Here is the function I wrote for this

function orderid_gen($ipaddy) {
$stamp = strtotime ("now");
$orderid = "$stamp$ipaddy";
$orderid = str_replace(".", "", "$orderid");

return $orderid;

}

Problem is I need a unique number less than 20chars. I was thinking of
making a table and placing a number in it then when client sites send sale
info to the script it will query that table extract that number then
increment by 1 and reinsert??

I would use myslq_insert_id() but this script is going to get alot of
traffic and volume and I am concerned on getting errors for duplicates in a
unique field.

Any help would be appreciated


--
Eric

Re: Unique Order ID"s high volume site HELP

am 17.12.2004 12:38:25 von Norman Peelman

"Eric Haskins" wrote in message
news:pxqwd.166943$6w6.23834@tornado.tampabay.rr.com...
> Hello all,
>
> I am built a frontend for a system that talks to a Credit gateway. I
> have run into a problem generating Unique Order ID's
>
> Here is the function I wrote for this
>
> function orderid_gen($ipaddy) {
> $stamp = strtotime ("now");
> $orderid = "$stamp$ipaddy";
> $orderid = str_replace(".", "", "$orderid");
>
> return $orderid;
>
> }
>
> Problem is I need a unique number less than 20chars. I was thinking of
> making a table and placing a number in it then when client sites send sale
> info to the script it will query that table extract that number then
> increment by 1 and reinsert??
>
> I would use myslq_insert_id() but this script is going to get alot of
> traffic and volume and I am concerned on getting errors for duplicates in
a
> unique field.
>
> Any help would be appreciated
>
>
> --
> Eric
>
>

What about 'uniqid()'?
http://us2.php.net/manual/en/function.uniqid.php

Norm
---
FREE Avatar Hosting at www.easyavatar.com

Re: Unique Order ID"s high volume site HELP

am 17.12.2004 18:16:12 von Tommy Gildseth

Eric Haskins wrote:

> Hello all,
>
> I am built a frontend for a system that talks to a Credit gateway. I
> have run into a problem generating Unique Order ID's
.......
> Problem is I need a unique number less than 20chars. I was thinking of
> making a table and placing a number in it then when client sites send sale
> info to the script it will query that table extract that number then
> increment by 1 and reinsert??
>
> I would use myslq_insert_id() but this script is going to get alot of
> traffic and volume and I am concerned on getting errors for duplicates in
> a unique field.

mysql_insert_id() does not return the value of auto incremented inserts from
other sessions.
So, the value returned by mysql_insert_id() is the insert ID generated by an
insert statement in that specific run of the script. It does not matter if
the same script is being run at the same time by another visitor.
If you haven't inserted any values into the table previously in that run of
the scrip, mysql_insert_id will return 0.

Bottom line is, you can be pretty sure that mysql_insert_id will be unique
if you have inserted a row into the table, no error occured, and you have
set up database table correctly.


--
Tommy

Re: Unique Order ID"s high volume site HELP

am 20.12.2004 02:44:18 von Peter

I had the same problem.

What i did was set up an orders table with an auto incrementing primary
key and used it as the order number. It has to be unique.

Tommy Gildseth wrote:
> Eric Haskins wrote:
>
>
>>Hello all,
>>
>> I am built a frontend for a system that talks to a Credit gateway. I
>>have run into a problem generating Unique Order ID's
>
> ......
>
>>Problem is I need a unique number less than 20chars. I was thinking of
>>making a table and placing a number in it then when client sites send sale
>>info to the script it will query that table extract that number then
>>increment by 1 and reinsert??
>>
>>I would use myslq_insert_id() but this script is going to get alot of
>>traffic and volume and I am concerned on getting errors for duplicates in
>>a unique field.
>
>
> mysql_insert_id() does not return the value of auto incremented inserts from
> other sessions.
> So, the value returned by mysql_insert_id() is the insert ID generated by an
> insert statement in that specific run of the script. It does not matter if
> the same script is being run at the same time by another visitor.
> If you haven't inserted any values into the table previously in that run of
> the scrip, mysql_insert_id will return 0.
>
> Bottom line is, you can be pretty sure that mysql_insert_id will be unique
> if you have inserted a row into the table, no error occured, and you have
> set up database table correctly.
>
>