/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Database/Log
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Database/Log/LoggingStatement.php (4716B)
startTime = microtime(true);
$this->loggedQuery = new LoggedQuery();
$this->loggedQuery->params = $params ?: $this->_compiledParams;
try {
$result = parent::execute($params);
} catch (Exception $e) {
/** @psalm-suppress UndefinedPropertyAssignment */
$e->queryString = $this->queryString;
$this->loggedQuery->error = $e;
$this->_log();
throw $e;
}
if (preg_match('/^(?!SELECT)/i', $this->queryString)) {
$this->loggedQuery->numRows = $this->rowCount();
$this->_log();
}
return $result;
}
/**
* @inheritDoc
*/
public function fetch($type = self::FETCH_TYPE_NUM)
{
$record = parent::fetch($type);
if ($this->loggedQuery) {
$this->loggedQuery->numRows = $this->rowCount();
$this->_log();
}
return $record;
}
/**
* @inheritDoc
*/
public function fetchAll($type = self::FETCH_TYPE_NUM)
{
$results = parent::fetchAll($type);
if ($this->loggedQuery) {
$this->loggedQuery->numRows = $this->rowCount();
$this->_log();
}
return $results;
}
/**
* Copies the logging data to the passed LoggedQuery and sends it
* to the logging system.
*
* @return void
*/
protected function _log(): void
{
if ($this->loggedQuery === null) {
return;
}
$this->loggedQuery->took = (int)round((microtime(true) - $this->startTime) * 1000, 0);
$this->loggedQuery->query = $this->queryString;
$this->getLogger()->debug((string)$this->loggedQuery, ['query' => $this->loggedQuery]);
$this->loggedQuery = null;
}
/**
* Wrapper for bindValue function to gather each parameter to be later used
* in the logger function.
*
* @param string|int $column Name or param position to be bound
* @param mixed $value The value to bind to variable in query
* @param string|int|null $type PDO type or name of configured Type class
* @return void
*/
public function bindValue($column, $value, $type = 'string'): void
{
parent::bindValue($column, $value, $type);
if ($type === null) {
$type = 'string';
}
if (!ctype_digit($type)) {
$value = $this->cast($value, $type)[0];
}
$this->_compiledParams[$column] = $value;
}
/**
* Sets a logger
*
* @param \Psr\Log\LoggerInterface $logger Logger object
* @return void
*/
public function setLogger(LoggerInterface $logger): void
{
$this->_logger = $logger;
}
/**
* Gets the logger object
*
* @return \Psr\Log\LoggerInterface logger instance
*/
public function getLogger(): LoggerInterface
{
return $this->_logger;
}
}