ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionProcessLockerDb.php
Go to the documentation of this file.
1<?php
2
26{
27 protected ?ilAtomQuery $atom_query = null;
28
29 public function __construct(private ilDBInterface $db)
30 {
31 $this->db = $db;
32 }
33
34 private function getTablesUsedDuringSolutionUpdate(): array
35 {
36 return [
37 ['name' => 'tst_solutions', 'sequence' => true],
38 ['name' => PassPresentedVariablesRepo::TABLE_NAME, 'sequence' => false]
39 ];
40 }
41
42 private function getTablesUsedDuringResultUpdate(): array
43 {
44 return [
45 ['name' => 'tst_test_result', 'sequence' => true]
46 ];
47 }
48
50 {
51 $tables = $this->getTablesUsedDuringSolutionUpdate();
52
53 $this->atom_query = $this->db->buildAtomQuery();
54 foreach ($tables as $table) {
55 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
56 }
57 }
58
60 {
61 $this->atom_query = $this->db->buildAtomQuery();
62 foreach ($this->getTablesUsedDuringResultUpdate() as $table) {
63 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
64 }
65 }
66
68 {
69 $this->atom_query = $this->db->buildAtomQuery();
70 foreach (array_merge(
73 ) as $table) {
74 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
75 }
76 }
77
79 {
80 $this->atom_query = $this->db->buildAtomQuery();
81 $this->atom_query->addTableLock('tst_result_cache');
82 $this->atom_query->addTableLock('tst_test_result')->lockSequence(true);
83 $this->atom_query->addTableLock('tst_solutions')->lockSequence(true);
84 }
85
86 protected function executeOperation(callable $operation): void
87 {
88 if ($this->atom_query !== null) {
89 $this->atom_query->addQueryCallable(function (ilDBInterface $ilDB) use ($operation) {
90 $operation();
91 });
92 $this->atom_query->run();
93 } else {
94 $operation();
95 }
96
97 $this->atom_query = null;
98 }
99}
Interface ilAtomQuery Use ilAtomQuery to fire Database-Actions which have to be done without beeing i...
Interface ilDBInterface.