1 | <?php |
||
30 | class DbQueryDependency extends Dependency |
||
31 | { |
||
32 | /** |
||
33 | * @var string|array|object the application component ID of the database connection, connection object or |
||
34 | * its array configuration. |
||
35 | * This field can be left blank, allowing query to determine connection automatically. |
||
36 | */ |
||
37 | public $db; |
||
38 | /** |
||
39 | * @var QueryInterface the query which result is used to determine if the dependency has been changed. |
||
40 | * Actual query method to be invoked is determined by [[method]]. |
||
41 | */ |
||
42 | public $query; |
||
43 | /** |
||
44 | * @var string|callable method which should be invoked in over the [[query]] object. |
||
45 | * |
||
46 | * If specified as a string an own query method with such name will be invoked, passing [[db]] value as its |
||
47 | * first argument. For example: `exists`, `all`. |
||
48 | * |
||
49 | * This field can be specified as a PHP callback of following signature: |
||
50 | * |
||
51 | * ```php |
||
52 | * function (QueryInterface $query, mixed $db) { |
||
53 | * //return mixed; |
||
54 | * } |
||
55 | * ``` |
||
56 | * |
||
57 | * If not set - [[QueryInterface::one()]] will be used. |
||
58 | */ |
||
59 | public $method; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * Generates the data needed to determine if dependency is changed. |
||
64 | * This method returns the query result |
||
65 | * @param Cache $cache the cache component that is currently evaluating this dependency |
||
66 | * @return mixed the data needed to determine if dependency has been changed. |
||
67 | * @throws InvalidConfigException on invalid configuration. |
||
68 | */ |
||
69 | 3 | protected function generateDependencyData($cache) |
|
92 | |||
93 | /** |
||
94 | * Executes the query according to [[method]] specification. |
||
95 | * @param QueryInterface $query query to be executed. |
||
96 | * @param mixed $db connection. |
||
97 | * @return mixed query result. |
||
98 | */ |
||
99 | 3 | private function executeQuery($query, $db) |
|
109 | } |