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

Posted by Richard Davey on 10/04/39 11:23

Hello Martin,

Monday, August 8, 2005, 4:07:47 PM, you wrote:

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

What data type does the execute function return? You're doing a
loose type comparison between $rows and zero (== rather than ===),
because it's a loose comparison a number of different results could
equal zero in this case. For example if execute() returned false your
code would assume an insert is required, which might not be the case.

If you're using MySQL then you may want to look at using a different
method for checking / inserting this data. Rather than a SELECT
followed by INSERT you could use an INSERT IGNORE which won't
duplicate data if it already exists. Or possibly REPLACE INTO -
depends how you need this to work (i.e. retain the oldest copy of the
data, or keep the newest). Look in the MySQL manual for those two
functions for more info.

Best regards,

Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
Zend Certified Engineer
"I do not fear computers. I fear the lack of them." - Isaac Asimov

 

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

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