Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Query.php
Go to the documentation of this file.
1 <?php
32 {
33 
39  protected $_query = '';
40 
46  protected $_queryType = 0;
47 
53  protected $_startedMicrotime = null;
54 
60  protected $_endedMicrotime = null;
61 
65  protected $_boundParams = array();
66 
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 
91  public function __clone()
92  {
93  $this->_boundParams = array();
94  $this->_endedMicrotime = null;
95  $this->start();
96  }
97 
106  public function start()
107  {
108  $this->_startedMicrotime = microtime(true);
109  }
110 
116  public function end()
117  {
118  $this->_endedMicrotime = microtime(true);
119  }
120 
126  public function hasEnded()
127  {
128  return $this->_endedMicrotime !== null;
129  }
130 
136  public function getQuery()
137  {
138  return $this->_query;
139  }
140 
146  public function getQueryType()
147  {
148  return $this->_queryType;
149  }
150 
156  public function bindParam($param, $variable)
157  {
158  $this->_boundParams[$param] = $variable;
159  }
160 
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 
179  public function getQueryParams()
180  {
181  return $this->_boundParams;
182  }
183 
190  public function getElapsedSecs()
191  {
192  if (null === $this->_endedMicrotime) {
193  return false;
194  }
195 
196  return $this->_endedMicrotime - $this->_startedMicrotime;
197  }
198 
204  public function getStartedMicrotime()
205  {
206  if(null === $this->_startedMicrotime) {
207  return false;
208  }
209 
211  }
212 }
213 
__construct($query, $queryType)
Definition: Query.php:79
$variable
Definition: variable.php:7
$value
Definition: gender.phtml:16
bindParam($param, $variable)
Definition: Query.php:156
bindParams(array $params)
Definition: Query.php:165
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18