<quote who="Terry Collins">

>       1 - obtains the highest publisher_id already in the table publisher
> (fields publisher_id, publisher, description)
>       2 - increments it to get the next value
>       3 - sets up the form for you to enter the new publisher name and
> description.
>         4 - posts the data and clears the form everytime you hit the
> "create" button


YOWZA! Don't do this! :)

Imagine if you had three people who got to stage three (sitting there
waiting to enter the form data)...

Person 1: maximumid = 4, increments to 5, waits on form
Person 2: maximumid = 4, increments to 5, waits on form
Person 3: maximumid = 4, increments to 5, waits on form

Then comes speedy person four...

Person 4: maximumid = 4, increments to 5, enters data and submits

Now the maximumid will actually be 5, but what happens when users 1, 2 and 3
get off their butss and submit? DATABASE CARNAGE!

You've been bitten by human threads. :)


What you should do, instead of querying and then putting this id in the
form, is do the query *in* your insert. Then you're leaving it up to the
database to sort out locking and problems like that. Most databases will
allow you to return the objectid or primary key of the field just
inserted/updated if you need that straight away.

Never do before time what you can do at the last minute (at least with
databases).

- Jeff


-- [EMAIL PROTECTED] --------------------------------- http://linux.conf.au/ --

                  ASCII stupid question, get a stupid ANSI.


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to