parallel execution of php code?

From: Date: Mon, 08 Aug 2005 15:07:47 +0000
Subject: parallel execution of php code?
Groups: php.general 
Request: Send a blank email to php-general+get-220223@lists.php.net to get a copy of this message
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

« previous php.general (#220223) next »