1 | <?php |
||
14 | class CacheableActiveQuery extends ActiveQuery |
||
15 | { |
||
16 | use ArrayableTrait; |
||
17 | |||
18 | /** |
||
19 | * @var array|null The cached query result |
||
20 | * @see setCachedResult() |
||
21 | */ |
||
22 | private $result; |
||
23 | |||
24 | /** |
||
25 | * @var array|null The criteria params that were set when the cached query result was set |
||
26 | * @see setCachedResult() |
||
27 | */ |
||
28 | private $resultCriteria; |
||
29 | |||
30 | /** |
||
31 | * @inheritdoc |
||
32 | */ |
||
33 | public function count($q = '*', $db = null) |
||
42 | |||
43 | /** |
||
44 | * @inheritdoc |
||
45 | */ |
||
46 | public function all($db = null) |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | public function one($db = null) |
||
69 | |||
70 | /** |
||
71 | * Returns the resulting domains set by [[setCachedResult()]], if the criteria params haven’t changed since then. |
||
72 | * |
||
73 | * @return array|null The resulting domains, or null if setCachedResult() was never called or the criteria has |
||
74 | * changed |
||
75 | * @see setCachedResult() |
||
76 | */ |
||
77 | public function getCachedResult() |
||
92 | |||
93 | /** |
||
94 | * Sets the resulting domains. |
||
95 | * |
||
96 | * If this is called, [[all()]] will return these domains rather than initiating a new SQL query, |
||
97 | * as long as none of the parameters have changed since setCachedResult() was called. |
||
98 | * |
||
99 | * @param array $objects The resulting objects. |
||
100 | * |
||
101 | * @see getCachedResult() |
||
102 | */ |
||
103 | public function setCachedResult(array $objects) |
||
108 | |||
109 | /** |
||
110 | * Returns an array of the current criteria attribute values. |
||
111 | * |
||
112 | * @return array |
||
113 | */ |
||
114 | public function getCriteria(): array |
||
118 | |||
119 | /** |
||
120 | * Returns the query's criteria attributes. |
||
121 | * |
||
122 | * @return string[] |
||
123 | */ |
||
124 | public function criteriaAttributes(): array |
||
143 | } |
||
144 |