You are here: parallel execution of php code? « PHP « IT news, forums, messages
parallel execution of php code?

Posted by Martin van den Berg on 10/04/67 11:23

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация