ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilAtomQueryLock.php
Go to the documentation of this file.
1<?php
2require_once('./Services/Database/interfaces/interface.ilAtomQuery.php');
3
12
16 protected $locked_table_full_names = array();
20 protected $locked_table_names = array();
21
22
28 public function run() {
29 $this->checkBeforeRun();
30 $this->runWithLocks();
31 }
32
33
37 protected function runWithLocks() {
38 $this->ilDBInstance->lockTables($this->getLocksForDBInstance());
39 try {
40 $this->runQueries();
41 } catch (Exception $e) {
42 $this->ilDBInstance->unlockTables();
43 throw $e;
44 }
45 $this->ilDBInstance->unlockTables();
46 }
47
48
53 protected function getLocksForDBInstance() {
54 $locks = array();
55 foreach ($this->tables as $table) {
56 $full_name = $table->getTableName() . $table->getAlias();
57 if (in_array($full_name, $this->locked_table_full_names)) {
59 }
60 $this->locked_table_full_names[] = $full_name;
61
62 if (!in_array($table->getTableName(), $this->locked_table_names)) {
63 $locks[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel() );
64 $this->locked_table_names[] = $table->getTableName();
65 if ($table->isLockSequence() && $this->ilDBInstance->sequenceExists($table->getTableName())) {
66 $locks[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel(), 'sequence' => true );
67 }
68 }
69 if ($table->getAlias()) {
70 $locks[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel(), 'alias' => $table->getAlias() );
71 }
72 }
73
74 return $locks;
75 }
76}
An exception for terminatinating execution or to throw for unit testing.
Class ilAtomQuery.
Class ilAtomQueryException.
Class ilAtomQueryLock.
run()
Fire your Queries.
Interface ilAtomQuery.