/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/debug_kit/src/Database/Log
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/debug_kit/src/Database/Log/DebugLog.php (4607B)
_logger = $logger;
$this->_connectionName = $name;
$this->_includeSchema = $includeSchema;
}
/**
* Set the schema include flag.
*
* @param bool $value Set
* @return $this
*/
public function setIncludeSchema(bool $value)
{
$this->_includeSchema = $value;
return $this;
}
/**
* Get the connection name.
*
* @return string
*/
public function name(): string
{
return $this->_connectionName;
}
/**
* Get the stored logs.
*
* @return array
*/
public function queries(): array
{
return $this->_queries;
}
/**
* Get the total time
*
* @return int
*/
public function totalTime(): int
{
return $this->_totalTime;
}
/**
* Get the total rows
*
* @return int
*/
public function totalRows(): int
{
return $this->_totalRows;
}
/**
* @inheritDoc
*/
public function log($level, $message, array $context = []): void
{
$query = $context['query'];
if ($this->_logger) {
$this->_logger->log($level, $message, $context);
}
if ($this->_includeSchema === false && $this->isSchemaQuery($query)) {
return;
}
$this->_totalTime += $query->took;
$this->_totalRows += $query->numRows;
$this->_queries[] = [
'query' => (string)$query,
'took' => $query->took,
'rows' => $query->numRows,
];
}
/**
* Sniff SQL statements for things only found in schema reflection.
*
* @param \Cake\Database\Log\LoggedQuery $query The query to check.
* @return bool
*/
protected function isSchemaQuery(LoggedQuery $query): bool
{
$querystring = $query->query;
return // Multiple engines
strpos($querystring, 'FROM information_schema') !== false ||
// Postgres
strpos($querystring, 'FROM pg_catalog') !== false ||
// MySQL
strpos($querystring, 'SHOW TABLE') === 0 ||
strpos($querystring, 'SHOW FULL COLUMNS') === 0 ||
strpos($querystring, 'SHOW INDEXES') === 0 ||
// Sqlite
strpos($querystring, 'FROM sqlite_master') !== false ||
strpos($querystring, 'PRAGMA') === 0 ||
// Sqlserver
strpos($querystring, 'FROM INFORMATION_SCHEMA') !== false ||
strpos($querystring, 'FROM sys.') !== false;
}
}