PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / libs / Zend / Db / Profiler / Query.php
matomo / app / libs / Zend / Db / Profiler Last commit date
Exception.php 2 years ago Firebug.php 2 years ago Query.php 2 years ago
Query.php
194 lines
1 <?php
2
3 namespace {
4 /**
5 * Zend Framework
6 *
7 * LICENSE
8 *
9 * This source file is subject to the new BSD license that is bundled
10 * with this package in the file LICENSE.txt.
11 * It is also available through the world-wide-web at this URL:
12 * http://framework.zend.com/license/new-bsd
13 * If you did not receive a copy of the license and are unable to
14 * obtain it through the world-wide-web, please send an email
15 * to license@zend.com so we can send you a copy immediately.
16 *
17 * @category Zend
18 * @package Zend_Db
19 * @subpackage Profiler
20 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
21 * @license http://framework.zend.com/license/new-bsd New BSD License
22 * @version $Id: Query.php 23775 2011-03-01 17:25:24Z ralph $
23 */
24 /**
25 * @category Zend
26 * @package Zend_Db
27 * @subpackage Profiler
28 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
29 * @license http://framework.zend.com/license/new-bsd New BSD License
30 */
31 class Zend_Db_Profiler_Query
32 {
33 /**
34 * SQL query string or user comment, set by $query argument in constructor.
35 *
36 * @var string
37 */
38 protected $_query = '';
39 /**
40 * One of the Zend_Db_Profiler constants for query type, set by $queryType argument in constructor.
41 *
42 * @var integer
43 */
44 protected $_queryType = 0;
45 /**
46 * Unix timestamp with microseconds when instantiated.
47 *
48 * @var float
49 */
50 protected $_startedMicrotime = null;
51 /**
52 * Unix timestamp with microseconds when self::queryEnd() was called.
53 *
54 * @var integer
55 */
56 protected $_endedMicrotime = null;
57 /**
58 * @var array
59 */
60 protected $_boundParams = array();
61 /**
62 * @var array
63 */
64 /**
65 * Class constructor. A query is about to be started, save the query text ($query) and its
66 * type (one of the Zend_Db_Profiler::* constants).
67 *
68 * @param string $query
69 * @param integer $queryType
70 * @return void
71 */
72 public function __construct($query, $queryType)
73 {
74 $this->_query = $query;
75 $this->_queryType = $queryType;
76 // by default, and for backward-compatibility, start the click ticking
77 $this->start();
78 }
79 /**
80 * Clone handler for the query object.
81 * @return void
82 */
83 public function __clone()
84 {
85 $this->_boundParams = array();
86 $this->_endedMicrotime = null;
87 $this->start();
88 }
89 /**
90 * Starts the elapsed time click ticking.
91 * This can be called subsequent to object creation,
92 * to restart the clock. For instance, this is useful
93 * right before executing a prepared query.
94 *
95 * @return void
96 */
97 public function start()
98 {
99 $this->_startedMicrotime = \microtime(\true);
100 }
101 /**
102 * Ends the query and records the time so that the elapsed time can be determined later.
103 *
104 * @return void
105 */
106 public function end()
107 {
108 $this->_endedMicrotime = \microtime(\true);
109 }
110 /**
111 * Returns true if and only if the query has ended.
112 *
113 * @return boolean
114 */
115 public function hasEnded()
116 {
117 return $this->_endedMicrotime !== null;
118 }
119 /**
120 * Get the original SQL text of the query.
121 *
122 * @return string
123 */
124 public function getQuery()
125 {
126 return $this->_query;
127 }
128 /**
129 * Get the type of this query (one of the Zend_Db_Profiler::* constants)
130 *
131 * @return integer
132 */
133 public function getQueryType()
134 {
135 return $this->_queryType;
136 }
137 /**
138 * @param string $param
139 * @param mixed $variable
140 * @return void
141 */
142 public function bindParam($param, $variable)
143 {
144 $this->_boundParams[$param] = $variable;
145 }
146 /**
147 * @param array $param
148 * @return void
149 */
150 public function bindParams(array $params)
151 {
152 if (\array_key_exists(0, $params)) {
153 \array_unshift($params, null);
154 unset($params[0]);
155 }
156 foreach ($params as $param => $value) {
157 $this->bindParam($param, $value);
158 }
159 }
160 /**
161 * @return array
162 */
163 public function getQueryParams()
164 {
165 return $this->_boundParams;
166 }
167 /**
168 * Get the elapsed time (in seconds) that the query ran.
169 * If the query has not yet ended, false is returned.
170 *
171 * @return float|false
172 */
173 public function getElapsedSecs()
174 {
175 if (null === $this->_endedMicrotime) {
176 return \false;
177 }
178 return $this->_endedMicrotime - $this->_startedMicrotime;
179 }
180 /**
181 * Get the time (in seconds) when the profiler started running.
182 *
183 * @return bool|float
184 */
185 public function getStartedMicrotime()
186 {
187 if (null === $this->_startedMicrotime) {
188 return \false;
189 }
190 return $this->_startedMicrotime;
191 }
192 }
193 }
194