ILIAS  release_8 Revision v8.24
class.ilAtomQueryLock.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
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 = array();
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[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel() );
84 $this->locked_table_names[] = $table->getTableName();
85 if ($table->isLockSequence() && $this->ilDBInstance->sequenceExists($table->getTableName())) {
86 $locks[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel(), 'sequence' => true );
87 }
88 }
89 if ($table->getAlias() !== '') {
90 $locks[] = array( 'name' => $table->getTableName(), 'type' => $table->getLockLevel(), 'alias' => $table->getAlias() );
91 }
92 }
93
94 return $locks;
95 }
96}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
run()
Fire your Queries.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...