3 ms·
The example is the wrong case. Unless you are using MyISAM tables (hint: 90%+ of the time you shouldn't), there's rarely a situation to LOCK TABLES as describe
by morgo 16y ago
The example is the wrong case. Unless you are using MyISAM tables (hint: 90%+ of the time you shouldn't), there's rarely a situation to LOCK TABLES as described.
Using transactions would make more sense:
try {
mysql_query("START TRANSACTION");
// ... do lots of queries here
mysql_query("COMMIT");
} catch(Exception $e) {
mysql_query("ROLLBACK");
}
- dlsspy 16y agoYou left out the code where you acquire the database connection and need to release it before returning as well as propagate the success or failure of the operation.