Re: [PHP] parallel execution of php code?

2005-08-09 Thread Martin van den Berg
> I have lots of places where I used to do this. Since MySQL 4.1 I've > changed it to something like: > > "INSERT INTO mytable SET id = 123, bla = '$x' ON DUPLICATE KEY UPDATE > bla='$x'" > > This saves you a query, and makes it easier to isolate the insert/ > update as it will play nicely with aut

Re: [PHP] parallel execution of php code?

2005-08-09 Thread Marcus Bointon
On 8 Aug 2005, at 16:07, Martin van den Berg wrote: $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 ) } I have lots of places where I used to

Re: [PHP] parallel execution of php code?

2005-08-08 Thread M Saleh EG
Check if you're using MySQL 4.1. If Yes use the subquery functionality. So you could have your query as following: "Insert into sometable where not id=NULL and id=Select id from mytable where bla like 'some pattern';" Not really sure if it would work thogh. Havent tried it yet. HTH. On 8/8/05,

RE: [PHP] parallel execution of php code?

2005-08-08 Thread Michael Sims
Martin van den Berg wrote: > 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 )

Re: [PHP] parallel execution of php code?

2005-08-08 Thread Richard Davey
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

Re: [PHP] parallel execution of php code?

2005-08-08 Thread Edward Vermillion
Martin van den Berg wrote: 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 ) { /* so