Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
SequenceEntityDao | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
getLastSequence | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Dao\Entities; |
6 | |
7 | use PeServer\Core\Database\DaoBase; |
8 | use PeServer\Core\Database\DaoTrait; |
9 | use PeServer\Core\Database\DatabaseRowResult; |
10 | use PeServer\Core\Database\DatabaseTableResult; |
11 | use PeServer\Core\Database\IDatabaseContext; |
12 | use PeServer\Core\Throws\InvalidOperationException; |
13 | use PeServer\Core\TypeUtility; |
14 | |
15 | class SequenceEntityDao extends DaoBase |
16 | { |
17 | use DaoTrait; |
18 | |
19 | #region function |
20 | |
21 | public function getLastSequence(): int |
22 | { |
23 | $result = $this->context->queryFirst('select last_insert_rowid()'); |
24 | $val = strval(current($result->fields)); |
25 | if (TypeUtility::tryParseInteger($val, $count)) { |
26 | return $count; |
27 | } |
28 | |
29 | throw new InvalidOperationException(); |
30 | } |
31 | |
32 | #endregion |
33 | } |