diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2016-05-19 12:34:40 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-05-21 01:59:03 +0200 |
commit | 7e3ce8352666af86d597e1fdce95bfe57531207e (patch) | |
tree | 4d0641773e8f1e740285ea7b6bfdf497409a5b78 /lib/private/DB/Adapter.php | |
parent | 59a85a4c76b80658d9373e3acf4f71b872b244a0 (diff) | |
download | nextcloud-server-7e3ce8352666af86d597e1fdce95bfe57531207e.tar.gz nextcloud-server-7e3ce8352666af86d597e1fdce95bfe57531207e.zip |
Add a method to lock a table
Diffstat (limited to 'lib/private/DB/Adapter.php')
-rw-r--r-- | lib/private/DB/Adapter.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php index 9522f768c88..bcced395cb7 100644 --- a/lib/private/DB/Adapter.php +++ b/lib/private/DB/Adapter.php @@ -58,6 +58,26 @@ class Adapter { } /** + * Create an exclusive read+write lock on a table + * + * @param string $tableName + * @since 9.1.0 + */ + public function lockTable($tableName) { + $this->conn->beginTransaction(); + $this->conn->executeUpdate('LOCK TABLE `' .$tableName . '` IN EXCLUSIVE MODE'); + } + + /** + * Release a previous acquired lock again + * + * @since 9.1.0 + */ + public function unlockTable() { + $this->conn->commit(); + } + + /** * Insert a row if the matching row does not exists. * * @param string $table The table name (will replace *PREFIX* with the actual prefix) |