Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Db_Profiler_Query Class Reference

Public Member Functions

 __construct ($query, $queryType)
 
 __clone ()
 
 start ()
 
 end ()
 
 hasEnded ()
 
 getQuery ()
 
 getQueryType ()
 
 bindParam ($param, $variable)
 
 bindParams (array $params)
 
 getQueryParams ()
 
 getElapsedSecs ()
 
 getStartedMicrotime ()
 

Protected Attributes

 $_query = ''
 
 $_queryType = 0
 
 $_startedMicrotime = null
 
 $_endedMicrotime = null
 
 $_boundParams = array()
 

Detailed Description

Definition at line 31 of file Query.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $query,
  $queryType 
)

Class constructor. A query is about to be started, save the query text ($query) and its type (one of the Zend_Db_Profiler::* constants).

Parameters
string$query
integer$queryType
Returns
void

Definition at line 79 of file Query.php.

80  {
81  $this->_query = $query;
82  $this->_queryType = $queryType;
83  // by default, and for backward-compatibility, start the click ticking
84  $this->start();
85  }

Member Function Documentation

◆ __clone()

__clone ( )

Clone handler for the query object.

Returns
void

Definition at line 91 of file Query.php.

92  {
93  $this->_boundParams = array();
94  $this->_endedMicrotime = null;
95  $this->start();
96  }

◆ bindParam()

bindParam (   $param,
  $variable 
)
Parameters
string$param
mixed$variable
Returns
void

Definition at line 156 of file Query.php.

157  {
158  $this->_boundParams[$param] = $variable;
159  }
$variable
Definition: variable.php:7

◆ bindParams()

bindParams ( array  $params)
Parameters
array$param
Returns
void

Definition at line 165 of file Query.php.

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  }
$value
Definition: gender.phtml:16
bindParam($param, $variable)
Definition: Query.php:156
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ end()

end ( )

Ends the query and records the time so that the elapsed time can be determined later.

Returns
void

Definition at line 116 of file Query.php.

117  {
118  $this->_endedMicrotime = microtime(true);
119  }

◆ getElapsedSecs()

getElapsedSecs ( )

Get the elapsed time (in seconds) that the query ran. If the query has not yet ended, false is returned.

Returns
float|false

Definition at line 190 of file Query.php.

191  {
192  if (null === $this->_endedMicrotime) {
193  return false;
194  }
195 
196  return $this->_endedMicrotime - $this->_startedMicrotime;
197  }

◆ getQuery()

getQuery ( )

Get the original SQL text of the query.

Returns
string

Definition at line 136 of file Query.php.

137  {
138  return $this->_query;
139  }

◆ getQueryParams()

getQueryParams ( )
Returns
array

Definition at line 179 of file Query.php.

180  {
181  return $this->_boundParams;
182  }

◆ getQueryType()

getQueryType ( )

Get the type of this query (one of the Zend_Db_Profiler::* constants)

Returns
integer

Definition at line 146 of file Query.php.

147  {
148  return $this->_queryType;
149  }

◆ getStartedMicrotime()

getStartedMicrotime ( )

Get the time (in seconds) when the profiler started running.

Returns
bool|float

Definition at line 204 of file Query.php.

205  {
206  if(null === $this->_startedMicrotime) {
207  return false;
208  }
209 
211  }

◆ hasEnded()

hasEnded ( )

Returns true if and only if the query has ended.

Returns
boolean

Definition at line 126 of file Query.php.

127  {
128  return $this->_endedMicrotime !== null;
129  }

◆ start()

start ( )

Starts the elapsed time click ticking. This can be called subsequent to object creation, to restart the clock. For instance, this is useful right before executing a prepared query.

Returns
void

Definition at line 106 of file Query.php.

107  {
108  $this->_startedMicrotime = microtime(true);
109  }

Field Documentation

◆ $_boundParams

$_boundParams = array()
protected

Definition at line 65 of file Query.php.

◆ $_endedMicrotime

$_endedMicrotime = null
protected

Definition at line 60 of file Query.php.

◆ $_query

$_query = ''
protected

Definition at line 39 of file Query.php.

◆ $_queryType

$_queryType = 0
protected

Definition at line 46 of file Query.php.

◆ $_startedMicrotime

$_startedMicrotime = null
protected

Definition at line 53 of file Query.php.


The documentation for this class was generated from the following file: