QueryRecorder
extends Instanceable
in package
Records PDO queries to display on exception page.
Tags
Table of Contents
Properties
- $_instances : array<class-string, static>
- Stores instances of classes with their class name as key.
- $_query_stack : array<string|int, mixed>
- $_query_stack_num : int
Methods
- getInstance() : static
- Get or make an instance of the class this was called on.
- getSqlStack() : array<string|int, mixed>
- Get an array of all the SQL queries that have been executed in this request.
- pushQuery() : void
- Add a query to the stack.
- compileQuery() : string
- Get a compiled SQL query with bound parameters replaced with their values and syntax highlighted.
- lastReleventBacktrace() : array<string|int, mixed>
- Get the last debug_backtrace entry which is not the file that executed this query or a database class.
Properties
$_instances
Stores instances of classes with their class name as key.
private
static array<class-string, static>
$_instances
= []
$_query_stack
private
array<string|int, mixed>
$_query_stack
= []
$_query_stack_num
private
int
$_query_stack_num
= 1
Methods
getInstance()
Get or make an instance of the class this was called on.
public
final static getInstance() : static
Return values
static —Instance of the class this was called on.
getSqlStack()
Get an array of all the SQL queries that have been executed in this request.
public
getSqlStack() : array<string|int, mixed>
Return values
array<string|int, mixed> —SQL queries
pushQuery()
Add a query to the stack.
public
pushQuery(string $sql, array<string|int, mixed> $params) : void
Parameters
- $sql : string
-
Raw SQL query executed
- $params : array<string|int, mixed>
-
Bound parameters used in the query
compileQuery()
Get a compiled SQL query with bound parameters replaced with their values and syntax highlighted.
private
compileQuery(string $sql, array<string|int, mixed> $params) : string
Parameters
- $sql : string
-
Raw SQL query
- $params : array<string|int, mixed>
-
Bound parameters
Return values
string —Compiled + syntax highlighted SQL query
lastReleventBacktrace()
Get the last debug_backtrace entry which is not the file that executed this query or a database class.
private
lastReleventBacktrace() : array<string|int, mixed>
Return values
array<string|int, mixed> —debug_backtrace entry