MockQuery
extends Query
in package
Query builder
Table of Contents
- $db : ConnectionInterface
- Pointer to database connection.
- $bindMarker : string
- Bind marker
- $binds : array<string|int, mixed>
- The binds and their values used for binding.
- $endTime : float
- The end time in seconds with microseconds for when this query was executed.
- $errorCode : int
- The error code, if any.
- $errorString : string
- The error message, if any.
- $finalQueryString : string
- The final query string after binding, etc.
- $originalQueryString : string
- The query string, as provided by the user.
- $startTime : string|float
- The start time in seconds with microseconds for when this query was executed.
- __construct() : mixed
- BaseQuery constructor.
- __toString() : string
- Return text representation of the query
- debugToolbarDisplay() : string
- Returns string to display in debug toolbar
- getDuration() : string
- Returns the duration of this query during execution, or null if the query has not been executed yet.
- getErrorCode() : int
- Returns the error code created while executing this statement.
- getErrorMessage() : string
- Returns the error message created while executing this statement.
- getOriginalQuery() : string
- Returns the original SQL that was passed into the system.
- getQuery() : string
- Returns the final, processed query string after binding, etal has been performed.
- getStartTime() : string|float
- Returns the start time in seconds with microseconds.
- hasError() : bool
- Reports whether this statement created an error not.
- isWriteType() : bool
- Determines if the statement is a write-type query or not.
- setBinds() : $this
- Will store the variables to bind into the query later.
- setDuration() : $this
- Records the execution time of the statement using microtime(true) for it's start and end values. If no end value is present, will use the current time to determine total duration.
- setError() : $this
- Stores the error description that happened for this query.
- setQuery() : $this
- Sets the raw query string to use for this statement.
- swapPrefix() : $this
- Swaps out one table prefix for a new one.
- compileBinds() : void
- Escapes and inserts any binds into the finalQueryString object.
- matchNamedBinds() : string
- Match bindings
- matchSimpleBinds() : string
- Match bindings
Properties
$db
Pointer to database connection.
public
ConnectionInterface
$db
Mainly for escaping features.
$bindMarker
Bind marker
protected
string
$bindMarker
= '?'
Character used to identify values in a prepared statement.
$binds
The binds and their values used for binding.
protected
array<string|int, mixed>
$binds
= []
$endTime
The end time in seconds with microseconds for when this query was executed.
protected
float
$endTime
$errorCode
The error code, if any.
protected
int
$errorCode
$errorString
The error message, if any.
protected
string
$errorString
$finalQueryString
The final query string after binding, etc.
protected
string
$finalQueryString
$originalQueryString
The query string, as provided by the user.
protected
string
$originalQueryString
$startTime
The start time in seconds with microseconds for when this query was executed.
protected
string|float
$startTime
Methods
__construct()
BaseQuery constructor.
public
__construct(ConnectionInterface &$db) : mixed
Parameters
- $db : ConnectionInterface
Return values
mixed —__toString()
Return text representation of the query
public
__toString() : string
Return values
string —debugToolbarDisplay()
Returns string to display in debug toolbar
public
debugToolbarDisplay() : string
Return values
string —getDuration()
Returns the duration of this query during execution, or null if the query has not been executed yet.
public
getDuration([int $decimals = 6 ]) : string
Parameters
- $decimals : int = 6
-
The accuracy of the returned time.
Return values
string —getErrorCode()
Returns the error code created while executing this statement.
public
getErrorCode() : int
Return values
int —getErrorMessage()
Returns the error message created while executing this statement.
public
getErrorMessage() : string
Return values
string —getOriginalQuery()
Returns the original SQL that was passed into the system.
public
getOriginalQuery() : string
Return values
string —getQuery()
Returns the final, processed query string after binding, etal has been performed.
public
getQuery() : string
Return values
string —getStartTime()
Returns the start time in seconds with microseconds.
public
getStartTime([bool $returnRaw = false ][, int $decimals = 6 ]) : string|float
Parameters
- $returnRaw : bool = false
- $decimals : int = 6
Return values
string|float —hasError()
Reports whether this statement created an error not.
public
hasError() : bool
Return values
bool —isWriteType()
Determines if the statement is a write-type query or not.
public
isWriteType() : bool
Return values
bool —setBinds()
Will store the variables to bind into the query later.
public
setBinds(array<string|int, mixed> $binds[, bool $setEscape = true ]) : $this
Parameters
- $binds : array<string|int, mixed>
- $setEscape : bool = true
Return values
$this —setDuration()
Records the execution time of the statement using microtime(true) for it's start and end values. If no end value is present, will use the current time to determine total duration.
public
setDuration(float $start[, float $end = null ]) : $this
Parameters
- $start : float
- $end : float = null
Return values
$this —setError()
Stores the error description that happened for this query.
public
setError(int $code, string $error) : $this
Parameters
- $code : int
- $error : string
Return values
$this —setQuery()
Sets the raw query string to use for this statement.
public
setQuery(string $sql[, mixed $binds = null ][, bool $setEscape = true ]) : $this
Parameters
- $sql : string
- $binds : mixed = null
- $setEscape : bool = true
Return values
$this —swapPrefix()
Swaps out one table prefix for a new one.
public
swapPrefix(string $orig, string $swap) : $this
Parameters
- $orig : string
- $swap : string
Return values
$this —compileBinds()
Escapes and inserts any binds into the finalQueryString object.
protected
compileBinds() : void
Tags
Return values
void —matchNamedBinds()
Match bindings
protected
matchNamedBinds(string $sql, array<string|int, mixed> $binds) : string
Parameters
- $sql : string
- $binds : array<string|int, mixed>
Return values
string —matchSimpleBinds()
Match bindings
protected
matchSimpleBinds(string $sql, array<string|int, mixed> $binds, int $bindCount, int $ml) : string
Parameters
- $sql : string
- $binds : array<string|int, mixed>
- $bindCount : int
- $ml : int