Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
indatabase.php
1<?php
2
4
10
12{
13 private Query $query;
15 private array $current = [];
17 private int $key = 0;
19 private bool $valid = false;
20
21 private Result $ormQueryResult;
22
23 public function __construct(int $userId, Counter\Loader $loader)
24 {
25 parent::__construct($userId, $loader);
26
27 $this->queryInit($userId);
28 $this->next();
29 }
30
31 public function rewind(): void
32 {
33 $this->key = 0;
34 $this->queryInit($this->userId);
35 $this->next();
36 }
37
38 public function current()
39 {
40 return $this->current;
41 }
42
43 public function key(): int
44 {
45 return $this->key;
46 }
47
48 public function next(): void
49 {
50 $this->key++;
51 $row = $this->ormQueryResult->fetch();
52 if ($row === false)
53 {
54 $this->valid = false;
55 unset($this->ormQueryResult);
56 return;
57 }
58
59 $this->valid = true;
60 $this->current = $row;
61 }
62
63 public function valid(): bool
64 {
65 return $this->valid;
66 }
67
68 public function getSize(): int
69 {
70 return $this->query->queryCountTotal();
71 }
72
73 public function updateState(array $rawCounters, array $types = [], array $logIds = []): void
74 {
75 $this->updateRawCounters();
76 }
77
78 protected function loadCounters(): void
79 {
80 $this->updateRawCounters();
81 }
82
83 private function queryInit(int $userId)
84 {
85 $this->query = CounterTable::query()
86 ->setSelect([
87 'VALUE',
88 'SONET_LOG_ID',
89 'GROUP_ID',
90 'TYPE'
91 ])
92 ->where('USER_ID', $userId);
93
94 $this->ormQueryResult = $this->query->exec();
95 }
96}
updateState(array $rawCounters, array $types=[], array $logIds=[])