ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilAtomQueryLock.php
Go to the documentation of this file.
1 <?php
2 require_once('./Services/Database/interfaces/interface.ilAtomQuery.php');
3 
11 class ilAtomQueryLock extends ilAtomQueryBase implements ilAtomQuery {
12 
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 }
Class ilAtomQuery.
run()
Fire your Queries.
Class ilAtomQueryLock.
Class ilAtomQueryException.
Interface ilAtomQuery.
Create styles array
The data for the language used.