Hi.

There is a one-query method to do that and it is even explicitly
documented: http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
(under LAST_INSERT_ID([expr])). This requires an UPDATE and using a
client API function like mysql_insert_id(). No locks needed and the
operation is atomic (i.e. no 'precision' trade-off).

Bye,

        Benjamin.

On Sun, Apr 14, 2002 at 09:11:03PM -0600, [EMAIL PROTECTED] wrote:
> I'd recomment PHP4 using pconnect and MySQL. And I'd /not/ use locking
> on the table. Run a query to update the row, then run a select to grab
> the current total. In the case of a counter, it doesn't require the
> precision that most things would. (i.e., it's okay if the row you read
> doesn't have the value you just set in the update.)
> 
> As far as performance goes, my PHP app can do 40+ queries in less that
> .05 seconds. So you shouldn't have problems there.
[...]

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to