ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilAtomQueryLock.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 {
33  protected array $locked_table_full_names = [];
37  protected array $locked_table_names = [];
38 
39 
45  public function run(): void
46  {
47  $this->checkBeforeRun();
48  $this->runWithLocks();
49  }
50 
51 
55  protected function runWithLocks(): void
56  {
57  $this->ilDBInstance->lockTables($this->getLocksForDBInstance());
58  try {
59  $this->runQueries();
60  } catch (Exception $e) {
61  $this->ilDBInstance->unlockTables();
62  throw $e;
63  }
64  $this->ilDBInstance->unlockTables();
65  }
66 
67 
72  protected function getLocksForDBInstance(): array
73  {
74  $locks = [];
75  foreach ($this->tables as $table) {
76  $full_name = $table->getTableName() . $table->getAlias();
77  if (in_array($full_name, $this->locked_table_full_names, true)) {
79  }
80  $this->locked_table_full_names[] = $full_name;
81 
82  if (!in_array($table->getTableName(), $this->locked_table_names, true)) {
83  $locks[] = [ 'name' => $table->getTableName(), 'type' => $table->getLockLevel() ];
84  $this->locked_table_names[] = $table->getTableName();
85  if ($table->isLockSequence() && $this->ilDBInstance->sequenceExists($table->getTableName())) {
86  $locks[] = [ 'name' => $table->getTableName(), 'type' => $table->getLockLevel(), 'sequence' => true ];
87  }
88  }
89  if ($table->getAlias() !== '') {
90  $locks[] = [ 'name' => $table->getTableName(), 'type' => $table->getLockLevel(), 'alias' => $table->getAlias() ];
91  }
92  }
93 
94  return $locks;
95  }
96 }
Class ilAtomQuery Use ilAtomQuery to fire Database-Actions which have to be done without beeing influ...
run()
Fire your Queries.
Class ilAtomQueryLock.
Class ilAtomQueryException.
Interface ilAtomQuery Use ilAtomQuery to fire Database-Actions which have to be done without beeing i...