Re: parallel execution of php code?
| From: | Marcus Bointon | Date: | Tue, 09 Aug 2005 08:21:13 +0000 |
| Subject: | Re: parallel execution of php code? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-220271@lists.php.net to get a copy of this message | ||
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 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 autocommit. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture marcus@synchromedia.co.uk | http://www.synchromedia.co.uk