in reply to MySQL "Counter"?

You don't need to use a special MySQL command. You can use an SQL statement to increment a field in a table like this:
UPDATE mytable SET myfield = myfield + 1;
According to SQL standard, such a statement is atomic. No two scripts could intercept each other calls and increment it only once. P.S. When programming databases, try not to use any database-dependent functions. Try to be portable.

Replies are listed 'Best First'.
Re: Re: MySQL "Counter"?
by valdez (Monsignor) on Feb 04, 2003 at 08:01 UTC

    If you need to know what is the value after the update, do as follow:

    $dbh->do('UPDATE mytable SET myfield = LAST_INSERT_ID(myfield + 1)'); ($myfield) = $dbh->selectrow_array('SELECT LAST_INSERT_ID()');

    This will work only with MySQL.

    Ciao, Valerio