Properties

$originalQueryString

$originalQueryString : string

The query string, as provided by the user.

Type

string

$finalQueryString

$finalQueryString : string

The final query string after binding, etc.

Type

string

$binds

$binds : array

The binds and their values used for binding.

Type

array

$bindMarker

$bindMarker : string

Bind marker

Character used to identify values in a prepared statement.

Type

string

$startTime

$startTime : float

The start time in seconds with microseconds for when this query was executed.

Type

float

$endTime

$endTime : float

The end time in seconds with microseconds for when this query was executed.

Type

float

$errorCode

$errorCode : integer

The error code, if any.

Type

integer

$errorString

$errorString : string

The error message, if any.

Type

string

Methods

__construct()

__construct(  $db) 

BaseQuery constructor.

Parameters

$db

ConnectionInterface

setQuery()

setQuery(string  $sql, mixed  $binds = null, boolean  $setEscape = true) : $this

Sets the raw query string to use for this statement.

Parameters

string $sql
mixed $binds
boolean $setEscape

Returns

$this

setBinds()

setBinds(array  $binds) : $this

Will store the variables to bind into the query later.

Parameters

array $binds

Returns

$this

getQuery()

getQuery() : string

Returns the final, processed query string after binding, etal has been performed.

Returns

string

setDuration()

setDuration(float  $start, float  $end = null) : $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.

Parameters

float $start
float $end

Returns

$this

getStartTime()

getStartTime(boolean  $returnRaw = false, integer  $decimals = 6) : string

Returns the start time in seconds with microseconds.

Parameters

boolean $returnRaw
integer $decimals

Returns

string

getDuration()

getDuration(integer  $decimals = 6) : string

Returns the duration of this query during execution, or null if the query has not been executed yet.

Parameters

integer $decimals

The accuracy of the returned time.

Returns

string

setError()

setError(integer  $code, string  $error) : $this

Stores the error description that happened for this query.

Parameters

integer $code
string $error

Returns

$this

hasError()

hasError() : boolean

Reports whether this statement created an error not.

Returns

boolean

getErrorCode()

getErrorCode() : integer

Returns the error code created while executing this statement.

Returns

integer

getErrorMessage()

getErrorMessage() : string

Returns the error message created while executing this statement.

Returns

string

isWriteType()

isWriteType() : boolean

Determines if the statement is a write-type query or not.

Returns

boolean

swapPrefix()

swapPrefix(string  $orig, string  $swap) : $this

Swaps out one table prefix for a new one.

Parameters

string $orig
string $swap

Returns

$this

getOriginalQuery()

getOriginalQuery() : string

Returns the original SQL that was passed into the system.

Returns

string

__toString()

__toString() : string

Return text representation of the query

Returns

string

compileBinds()

compileBinds() : null|void

Escapes and inserts any binds into the finalQueryString object.

Returns

null|void

matchNamedBinds()

matchNamedBinds(string  $sql, array  $binds) : string

Match bindings

Parameters

string $sql
array $binds

Returns

string

matchSimpleBinds()

matchSimpleBinds(string  $sql, array  $binds, integer  $bindCount, integer  $ml) : string

Match bindings

Parameters

string $sql
array $binds
integer $bindCount
integer $ml

Returns

string