3 declare(strict_types=1);
84 static::checkIsolationLevel($isolation_level);
108 $ilTableLock =
new ilTableLock($table_name, $this->ilDBInstance);
110 $this->tables[] = $ilTableLock;
161 abstract public function run(): void;
173 static::checkIsolationLevel($isolation_level);
174 static::checkAnomaly($anomaly);
176 return in_array($anomaly, static::getPossibleAnomalies($isolation_level));
184 static::checkIsolationLevel($isolation_level);
195 if (in_array($isolation_level, array(
203 if (!in_array($isolation_level, self::$available_isolations_levels)) {
213 if (!in_array($anomaly, self::$possible_anomalies)) {
223 if (!($this->query instanceof \
Traversable) && (is_array($this->query) && 0 === count($this->query))) {
227 foreach ($this->query as
$query) {
236 if (!is_callable($query)) {
239 if (is_array($query)) {
242 if (is_string($query)) {
246 $is_a_closure = ($query instanceof
Closure);
247 if (!$is_a_closure) {
249 foreach ($ref->getMethods() as $method) {
250 if ($method->getName() ===
'__invoke') {
259 $parameters = $ref->getParameters();
260 if (count($parameters) !== 1) {
263 $reflectionClass = $parameters[0]->getType();
264 return $reflectionClass && $reflectionClass->getName() === ilDBInterface::class;
272 $has_write_locks =
false;
273 foreach ($this->tables as $table) {
275 $has_write_locks =
true;
279 return $has_write_locks;
288 $query($this->ilDBInstance);
302 if (count($this->tables) === 0) {
const DB_ATOM_CLOSURE_NONE
static array $available_isolations_levels
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ISOLATION_SERIALIZABLE
const ANO_NON_REPEATED_READ
static checkIsolationLevel(int $isolation_level)
addTableLock(string $table_name)
Add table-names which are influenced by your queries, MyISAm has to lock those tables.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const DB_ATOM_LOCK_WRONG_LEVEL
const ISOLATION_READ_COMMITED
const ISOLATION_REPEATED_READ
ilDBInterface $ilDBInstance
static checkAnomaly(int $anomaly)
const DB_ATOM_CLOSURE_WRONG_FORMAT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addQueryCallable(callable $query)
All action on the database during this isolation has to be passed as Callable to ilAtomQuery.
static isThereRiskThat(int $isolation_level, int $anomaly)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilDBInterface $ilDBInstance, int $isolation_level=ilAtomQuery::ISOLATION_SERIALIZABLE)
ilAtomQuery constructor.
const DB_ATOM_CLOSURE_ALREADY_SET
static array $possible_anomalies
const DB_ATOM_ISO_WRONG_LEVEL
const DB_ATOM_LOCK_NO_TABLE
const DB_ATOM_ANO_NOT_AVAILABLE
checkCallable(callable $query)
static getPossibleAnomalies(int $isolation_level)
static array $anomalies_map
const ISOLATION_READ_UNCOMMITED
replaceQueryCallable(callable $query)