1 | <?php |
||
13 | class CacheableActiveQuery extends ActiveQuery |
||
14 | { |
||
15 | use ArrayableTrait; |
||
16 | |||
17 | /** |
||
18 | * @var array|null The cached query result |
||
19 | * @see setCachedResult() |
||
20 | */ |
||
21 | private $result; |
||
22 | |||
23 | /** |
||
24 | * @var array|null The criteria params that were set when the cached query result was set |
||
25 | * @see setCachedResult() |
||
26 | */ |
||
27 | private $resultCriteria; |
||
28 | |||
29 | /** |
||
30 | * @inheritdoc |
||
31 | */ |
||
32 | public function count($q = '*', $db = null) |
||
41 | |||
42 | /** |
||
43 | * @inheritdoc |
||
44 | */ |
||
45 | public function all($db = null) |
||
54 | |||
55 | /** |
||
56 | * @inheritdoc |
||
57 | */ |
||
58 | public function one($db = null) |
||
66 | |||
67 | /** |
||
68 | * Returns the results set by [[setCachedResult()]], if the criteria params haven’t changed since then. |
||
69 | * |
||
70 | * @return array|null The results, or null if setCachedResult() was never called or the criteria has |
||
71 | * changed |
||
72 | * @see setCachedResult() |
||
73 | */ |
||
74 | public function getCachedResult() |
||
89 | |||
90 | /** |
||
91 | * Sets the results. |
||
92 | * |
||
93 | * If this is called, [[all()]] will return these domains rather than initiating a new SQL query, |
||
94 | * as long as none of the parameters have changed since setCachedResult() was called. |
||
95 | * |
||
96 | * @param array $objects The resulting objects. |
||
97 | * |
||
98 | * @see getCachedResult() |
||
99 | */ |
||
100 | public function setCachedResult(array $objects) |
||
105 | |||
106 | /** |
||
107 | * Clears the results. |
||
108 | * |
||
109 | * @see getCachedResult() |
||
110 | */ |
||
111 | public function clearCachedResult() |
||
116 | |||
117 | /** |
||
118 | * Returns an array of the current criteria attribute values. |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | public function getCriteria(): array |
||
126 | |||
127 | /** |
||
128 | * @noinspection PhpDocMissingThrowsInspection |
||
129 | * |
||
130 | * Returns the query's criteria attributes. |
||
131 | * |
||
132 | * @return string[] |
||
133 | */ |
||
134 | public function criteriaAttributes(): array |
||
154 | } |
||
155 |