automatic call reference creation

This is a discussion on automatic call reference creation within the alt.comp.lang.php forums, part of the PHP Programming Forums category; hi all, i need to create an automatic call reference. i though it would work using the date as ccyymmdd ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-10-2004
Gawie Marais
 
Posts: n/a
Default automatic call reference creation

hi all,

i need to create an automatic call reference. i though it would work using
the date as ccyymmdd and by adding a '001', '002', etc to the end.

now, i know how to format the date but how would i increment the 001, 002 at
the end... ? i understand that i would have to check back to the database to
check the last one used. but how... ?

alternatively is to just generate a random number, check it against the
database to see if it's not already used. if not use it. if its used
already, just create another one... ?

OR

do you guys have any laternative suggestions ?


Regards,

Gawie.


Reply With Quote
  #2 (permalink)  
Old 06-10-2004
Alvaro G Vicario
 
Posts: n/a
Default Re: automatic call reference creation

*** Gawie Marais wrote/escribió (Thu, 10 Jun 2004 11:52:01 +0200):
> i need to create an automatic call reference. i though it would work using
> the date as ccyymmdd and by adding a '001', '002', etc to the end.


What database type are you using? Most DBMS have autoincrement fields.


--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Reply With Quote
  #3 (permalink)  
Old 06-10-2004
Gawie Marais
 
Posts: n/a
Default Re: automatic call reference creation

i'm using MySQL 3.23 and i am aware of the auto_increment function.

but i was hoping to use the date i..e 20040101 plus a 001 added to the back
of that and store that into a field. but the problem is, how do i know what
the next available 00? is ??

gm./


"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
message news:sjyfsbzqaksc.1s1cl2pntkd7a.dlg@40tude.net...
> *** Gawie Marais wrote/escribió (Thu, 10 Jun 2004 11:52:01 +0200):
> > i need to create an automatic call reference. i though it would work

using
> > the date as ccyymmdd and by adding a '001', '002', etc to the end.

>
> What database type are you using? Most DBMS have autoincrement fields.
>
>
> --
> --
> -- Álvaro G. Vicario - Burgos, Spain
> --



Reply With Quote
  #4 (permalink)  
Old 06-10-2004
Alvaro G Vicario
 
Posts: n/a
Default Re: automatic call reference creation

*** Gawie Marais wrote/escribió (Thu, 10 Jun 2004 12:11:22 +0200):
> but i was hoping to use the date i..e 20040101 plus a 001 added to the back
> of that and store that into a field. but the problem is, how do i know what
> the next available 00? is ??


I can think of two options, both involving a separate numeric ID field.

1) Use ID column as autoincremental. Insert new record, leaving date field
empty. Read last inserted ID. Update date field.

2) SELECT MAX(id) as previous_id FROM table. Insert new record using
previous_id+1.


--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Reply With Quote
  #5 (permalink)  
Old 06-10-2004
Alvaro G Vicario
 
Posts: n/a
Default Re: automatic call reference creation

*** Alvaro G Vicario wrote/escribió (Thu, 10 Jun 2004 13:32:22 +0200):
> I can think of two options, both involving a separate numeric ID field.


Or even easier, just keep one date_id field:

200410060001

When inserting new records, you can check for maximum value using MAX(),
get the substring with 0001, convert to numeric and increment it.

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Reply With Quote
  #6 (permalink)  
Old 06-10-2004
Gawie Marais
 
Posts: n/a
Default Re: automatic call reference creation

sounds as a piece of cake... if you know php raw coding.... :(



"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
message news:1qr41i7pzp1by.133phn1r28voi.dlg@40tude.net...
> *** Alvaro G Vicario wrote/escribió (Thu, 10 Jun 2004 13:32:22 +0200):
> > I can think of two options, both involving a separate numeric ID field.

>
> Or even easier, just keep one date_id field:
>
> 200410060001
>
> When inserting new records, you can check for maximum value using MAX(),
> get the substring with 0001, convert to numeric and increment it.
>
> --
> --
> -- Álvaro G. Vicario - Burgos, Spain
> --



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:00 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0