abstract class SQLExpression (View source)

Abstract base class for an object representing an SQL query.

The various parts of the SQL query can be manipulated individually.

Properties

protected array $replacementsOld

Keep an internal register of find/replace pairs to execute when it's time to actually get the query SQL.

protected array $replacementsNew

Keep an internal register of find/replace pairs to execute when it's time to actually get the query SQL.

Methods

public
replaceText(string $old, string $new)

Swap some text in the SQL query with another.

public
string
__toString()

Return the generated SQL string for this query

public
renameTable(string $old, string $new)

Swap the use of one table with another.

public
bool
isEmpty()

Determine if this query is empty, and thus cannot be executed

public
string
sql(array $parameters = [])

Generate the SQL statement for this query.

public
execute()

Execute this query.

protected
copyTo(SQLExpression $object)

Copies the query parameters contained in this object to another SQLExpression

Details

replaceText(string $old, string $new)

Swap some text in the SQL query with another.

Note that values in parameters will not be replaced

Parameters

string $old

The old text (escaped)

string $new

The new text (escaped)

string __toString()

Return the generated SQL string for this query

Return Value

string

renameTable(string $old, string $new)

Swap the use of one table with another.

Parameters

string $old

Name of the old table (unquoted, escaped)

string $new

Name of the new table (unquoted, escaped)

abstract bool isEmpty()

Determine if this query is empty, and thus cannot be executed

Return Value

bool

Flag indicating that this query is empty

string sql(array $parameters = [])

Generate the SQL statement for this query.

Parameters

array $parameters

Out variable for parameters required for this query

Return Value

string

The completed SQL query

Query execute()

Execute this query.

Return Value

Query

protected copyTo(SQLExpression $object)

Copies the query parameters contained in this object to another SQLExpression

Parameters

SQLExpression $object

The object to copy properties to