ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAtomQueryLock.php
Go to the documentation of this file.
1 <?php
2 
11 {
12 
16  protected $locked_table_full_names = array();
20  protected $locked_table_names = array();
21 
22 
28  public function run()
29  {
30  $this->checkBeforeRun();
31  $this->runWithLocks();
32  }
33 
34 
38  protected function runWithLocks()
39  {
40  $this->ilDBInstance->lockTables($this->getLocksForDBInstance());
41  try {
42  $this->runQueries();
43  } catch (Exception $e) {
44  $this->ilDBInstance->unlockTables();
45  throw $e;
46  }
47  $this->ilDBInstance->unlockTables();
48  }
49 
50 
55  protected function getLocksForDBInstance()
56  {
57  $locks = array();
58  foreach ($this->tables as $table) {
59  $full_name = $table->getTableName() . $table->getAlias();
60  if (in_array($full_name, $this->locked_table_full_names)) {
62  }
63  $this->locked_table_full_names[] = $full_name;
64 
65  if (!in_array($table->getTableName(), $this->locked_table_names)) {
66  $locks[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel() );
67  $this->locked_table_names[] = $table->getTableName();
68  if ($table->isLockSequence() && $this->ilDBInstance->sequenceExists($table->getTableName())) {
69  $locks[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel(), 'sequence' => true );
70  }
71  }
72  if ($table->getAlias()) {
73  $locks[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel(), 'alias' => $table->getAlias() );
74  }
75  }
76 
77  return $locks;
78  }
79 }
Class ilAtomQuery.
run()
Fire your Queries.
Class ilAtomQueryLock.
Class ilAtomQueryException.
Interface ilAtomQuery.