1 | <?php |
||
31 | class Sequenzer |
||
32 | { |
||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | const SEQUENZER_TABLE = 'tx_aoedbsequenzer_sequenz'; |
||
37 | |||
38 | /** |
||
39 | * @var \mysqli |
||
40 | */ |
||
41 | private $dbLink; |
||
42 | |||
43 | /** |
||
44 | * @var integer |
||
45 | */ |
||
46 | private $defaultStart = 0; |
||
47 | |||
48 | /** |
||
49 | * @var integer |
||
50 | */ |
||
51 | private $defaultOffset = 1; |
||
52 | |||
53 | /** |
||
54 | * @var integer |
||
55 | */ |
||
56 | private $checkInterval = 120; |
||
57 | |||
58 | /** |
||
59 | * @param integer $defaultStart to set |
||
60 | */ |
||
61 | public function setDefaultStart($defaultStart) |
||
65 | |||
66 | /** |
||
67 | * @param integer $defaultOffset to set |
||
68 | */ |
||
69 | public function setDefaultOffset($defaultOffset) |
||
73 | |||
74 | /** |
||
75 | * sets mysql dblink with DB connection |
||
76 | * @param null $dbLink |
||
77 | */ |
||
78 | public function setDbLink($dbLink = null) |
||
86 | |||
87 | /** |
||
88 | * returns next free id in the sequenz of the table |
||
89 | * @param $table |
||
90 | * @param int $depth |
||
91 | * @return int |
||
92 | * @throws \Exception |
||
93 | */ |
||
94 | public function getNextIdForTable($table, $depth = 0) |
||
129 | |||
130 | /** |
||
131 | * Gets the default start value for a given table. |
||
132 | * @param $table |
||
133 | * @return int |
||
134 | * @throws \Exception |
||
135 | */ |
||
136 | private function getDefaultStartValue($table) |
||
145 | |||
146 | /** |
||
147 | * if no sehduler entry for the table yet exists, this method initialises the sequenzer to fit offest and start and current max value in the table |
||
148 | * |
||
149 | * @param string $table |
||
150 | */ |
||
151 | private function initSequenzerForTable($table) |
||
157 | |||
158 | /** |
||
159 | * @param $string |
||
160 | * @return string |
||
161 | */ |
||
162 | private function escapeString($string) |
||
166 | |||
167 | /** |
||
168 | * @param $sql |
||
169 | * @return bool|\mysqli_result |
||
170 | * @throws \Exception |
||
171 | */ |
||
172 | private function query($sql) |
||
173 | { |
||
174 | $result = mysqli_query($this->dbLink, $sql); |
||
175 | if (mysqli_error($this->dbLink)) { |
||
185 |