parallel execution of php code?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have this piece of php-code which inserts data into a database.
Before inserting it must verify if the data is unique. The php code
looks something like:

$query = "SELECT id FROM mytable WHERE bla LIKE " . $x .";
$rows = execute( $query )
if ( $rows == 0 )
{
   /* some more processing */
  $query = "INSERT INTO mytable ...... etc etc
  execute( $query )
}

Now here is the problem: when the user enters the page, and directly
refreshes the record is inserted twice.... Is is possible that both
requests are processed simulatiounsly by the server (apache on linux)?
And can I add something like a critical section or semaphore to
overcome this problem.

Thanx,

Martin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux