PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
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 6 years ago Firebug.php 6 years ago Query.php 6 years ago
Query.php
214 lines
1 <?php
2 /**
3 * Zend Framework
4 *
5 * LICENSE
6 *
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category Zend
16 * @package Zend_Db
17 * @subpackage Profiler
18 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Query.php 23775 2011-03-01 17:25:24Z ralph $
21 */
22
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 /**
35 * SQL query string or user comment, set by $query argument in constructor.
36 *
37 * @var string
38 */
39 protected $_query = '';
40
41 /**
42 * One of the Zend_Db_Profiler constants for query type, set by $queryType argument in constructor.
43 *
44 * @var integer
45 */
46 protected $_queryType = 0;
47
48 /**
49 * Unix timestamp with microseconds when instantiated.
50 *
51 * @var float
52 */
53 protected $_startedMicrotime = null;
54
55 /**
56 * Unix timestamp with microseconds when self::queryEnd() was called.
57 *
58 * @var integer
59 */
60 protected $_endedMicrotime = null;
61
62 /**
63 * @var array
64 */
65 protected $_boundParams = array();
66
67 /**
68 * @var array
69 */
70
71 /**
72 * Class constructor. A query is about to be started, save the query text ($query) and its
73 * type (one of the Zend_Db_Profiler::* constants).
74 *
75 * @param string $query
76 * @param integer $queryType
77 * @return void
78 */
79 public function __construct($query, $queryType)
80 {
81 $this->_query = $query;
82 $this->_queryType = $queryType;
83 // by default, and for backward-compatibility, start the click ticking
84 $this->start();
85 }
86
87 /**
88 * Clone handler for the query object.
89 * @return void
90 */
91 public function __clone()
92 {
93 $this->_boundParams = array();
94 $this->_endedMicrotime = null;
95 $this->start();
96 }
97
98 /**
99 * Starts the elapsed time click ticking.
100 * This can be called subsequent to object creation,
101 * to restart the clock. For instance, this is useful
102 * right before executing a prepared query.
103 *
104 * @return void
105 */
106 public function start()
107 {
108 $this->_startedMicrotime = microtime(true);
109 }
110
111 /**
112 * Ends the query and records the time so that the elapsed time can be determined later.
113 *
114 * @return void
115 */
116 public function end()
117 {
118 $this->_endedMicrotime = microtime(true);
119 }
120
121 /**
122 * Returns true if and only if the query has ended.
123 *
124 * @return boolean
125 */
126 public function hasEnded()
127 {
128 return $this->_endedMicrotime !== null;
129 }
130
131 /**
132 * Get the original SQL text of the query.
133 *
134 * @return string
135 */
136 public function getQuery()
137 {
138 return $this->_query;
139 }
140
141 /**
142 * Get the type of this query (one of the Zend_Db_Profiler::* constants)
143 *
144 * @return integer
145 */
146 public function getQueryType()
147 {
148 return $this->_queryType;
149 }
150
151 /**
152 * @param string $param
153 * @param mixed $variable
154 * @return void
155 */
156 public function bindParam($param, $variable)
157 {
158 $this->_boundParams[$param] = $variable;
159 }
160
161 /**
162 * @param array $param
163 * @return void
164 */
165 public function bindParams(array $params)
166 {
167 if (array_key_exists(0, $params)) {
168 array_unshift($params, null);
169 unset($params[0]);
170 }
171 foreach ($params as $param => $value) {
172 $this->bindParam($param, $value);
173 }
174 }
175
176 /**
177 * @return array
178 */
179 public function getQueryParams()
180 {
181 return $this->_boundParams;
182 }
183
184 /**
185 * Get the elapsed time (in seconds) that the query ran.
186 * If the query has not yet ended, false is returned.
187 *
188 * @return float|false
189 */
190 public function getElapsedSecs()
191 {
192 if (null === $this->_endedMicrotime) {
193 return false;
194 }
195
196 return $this->_endedMicrotime - $this->_startedMicrotime;
197 }
198
199 /**
200 * Get the time (in seconds) when the profiler started running.
201 *
202 * @return bool|float
203 */
204 public function getStartedMicrotime()
205 {
206 if(null === $this->_startedMicrotime) {
207 return false;
208 }
209
210 return $this->_startedMicrotime;
211 }
212 }
213
214