class DMLStatement extends Statement

The class JsonSQLStatement represents a prepared statement and, after the statement is executed, an associated result set.

Properties

protected JsonSQL $jsonsql from Statement
protected object $request from Statement
protected array $result from Statement
protected int $rowCount from Statement
protected array $params from Statement
protected Engine $engine from Statement
private mixed|null $builtins
private mixed|null $parser

Methods

__construct(JsonSQL $jsonsql, stdClass $request)

Class Constructor

create(JsonSQL $jsonsql, stdClass $request)

Statement factory

from Statement
bool
bindValue(mixed $parameter, mixed $value, int $type = \PDO::PARAM_STR)

Binds a value to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement.

from Statement
bool
bindParam(mixed $parameter, mixed $variable, int $type = \PDO::PARAM_STR)

Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement.

from Statement
bool
execute(array $parameters = array())

Executes a prepared statement.

from Statement
int
rowCount()

Returns the number of rows affected by the last SQL statement

from Statement
int
columnCount()

Returns the number of columns in the result set

from Statement
void
checkValue(string $value, int $type = \PDO::PARAM_STR)

Checks if a value corresponds to its type and if it is safety in case of string

from Statement
bool
executeCompoundSelect()

Executes a prepared select statement with set opertations.

bool
executeSelect()

Executes a prepared select statement.

bool
executeInsert()

Executes a prepared insert statement.

bool
executeUpdate()

Executes a prepared update statement.

bool
executeDelete()

Executes a prepared delete statement.

bool
executeCreateTable()

function executeCreateTable

bool
executeAlterTable()

function executeAlterTable

bool
executeTruncate()

Executes a prepared 'truncate' statement.

bool
executeDropTable()

function executeDropTable

mixed
fetch()

Fetches the next row from a result set

mixed
fetchColumn(int $c = 0)

Returns a single column from the next row of a result set

array
fetchAll()

Returns an array containing all of the result set rows

array
makeExpressionVariables(stdClass $row)

From the given row, built an array containing all the variables in the scope of the running request.

string|bool
evaluate(string $conditions, object $row)

Evaluates a condition with the values of the given row.

array
select()

Selects rows that satisfy the where clause of the request.

object|null
joins(int $len)

Returns the next row resulting from the joining of tables in the query.

bool
isExpression(string $string)

Checks if a string contains an expression.

bool
isBuiltin(string $value)

Determines if the given value is a builtin value.

array
project(array $scope)

Realizes the operation of projection of result set

mixed
fieldValue(stdClass $row, mixed $column)

Returns the value of a field

array
aggregate(array $result)

Performs group by clause on the given result set, if any

void
resetAggregates(array $aggregates)

Initializes aggregate functions for all columns in the query

array
sort(array $result)

Sorts the result set according to the 'order by' clause.

array
limit(array $result)

Applies the 'limit' clause on the result set

Details

at line 62
__construct(JsonSQL $jsonsql, stdClass $request)

Class Constructor

Parameters

JsonSQL $jsonsql The JsonSQL instance
stdClass $request The prepared statement

in Statement at line 109
create(JsonSQL $jsonsql, stdClass $request)

Statement factory

Parameters

JsonSQL $jsonsql The JsonSQL instance
stdClass $request &$request The prepared statement

in Statement at line 138
bool bindValue(mixed $parameter, mixed $value, int $type = \PDO::PARAM_STR)

Binds a value to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement.

Parameters

mixed $parameter The parameter identifier
mixed $value The value to bind to the parameter
int $type The data type for the parameter using the PDO::PARAM_* constants.

Return Value

bool true on success or false on failure.

in Statement at line 189
bool bindParam(mixed $parameter, mixed $variable, int $type = \PDO::PARAM_STR)

Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement.

the variable is bound as a reference and will only be evaluated at the time that execute() is called.

Parameters

mixed $parameter The parameter identifier
mixed $variable &$variable The variable to bind to the parameter
int $type The data type for the parameter using the PDO::PARAM_* constants.

Return Value

bool true on success or false on failure.

in Statement at line 202
bool execute(array $parameters = array())

Executes a prepared statement.

Parameters

array $parameters An array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as PDO::PARAM_STR.

Return Value

bool true on success or false on failure.

in Statement at line 242
int rowCount()

Returns the number of rows affected by the last SQL statement

Return Value

int The number of rows.

in Statement at line 253
int columnCount()

Returns the number of columns in the result set

Return Value

int The number of columns in the result set. If there is no result set, returns 0.

in Statement at line 266
protected void checkValue(string $value, int $type = \PDO::PARAM_STR)

Checks if a value corresponds to its type and if it is safety in case of string

Parameters

string $value The value
int $type The expected type

Return Value

void

Exceptions

JsonSQLException

at line 132
protected bool executeCompoundSelect()

Executes a prepared select statement with set opertations.

Return Value

bool Always true.

at line 114
protected bool executeSelect()

Executes a prepared select statement.

Return Value

bool Always true.

at line 182
protected bool executeInsert()

Executes a prepared insert statement.

Return Value

bool Always true.

at line 220
protected bool executeUpdate()

Executes a prepared update statement.

Return Value

bool Always true.

at line 249
protected bool executeDelete()

Executes a prepared delete statement.

Return Value

bool Always true.

at line 646
protected bool executeCreateTable()

function executeCreateTable

Return Value

bool TRUE.

Exceptions

JsonSQLException

at line 658
protected bool executeAlterTable()

function executeAlterTable

Return Value

bool TRUE.

Exceptions

JsonSQLException

at line 269
protected bool executeTruncate()

Executes a prepared 'truncate' statement.

Return Value

bool Always true.

at line 670
protected bool executeDropTable()

function executeDropTable

Return Value

bool TRUE.

Exceptions

JsonSQLException

at line 82
mixed fetch()

Fetches the next row from a result set

Return Value

mixed The next row from a result set.

at line 93
mixed fetchColumn(int $c = 0)

Returns a single column from the next row of a result set

Parameters

int $c The parameter identifier

Return Value

mixed a single column from the next row of a result set or false

at line 104
array fetchAll()

Returns an array containing all of the result set rows

Return Value

array the array of rows in the result set or false

at line 285
protected array makeExpressionVariables(stdClass $row)

From the given row, built an array containing all the variables in the scope of the running request.

Parameters

stdClass $row The table row

Return Value

array The array of variables.

at line 311
protected string|bool evaluate(string $conditions, object $row)

Evaluates a condition with the values of the given row.

Parameters

string $conditions the condition to evaluate
object $row The table row

Return Value

string|bool The evaluation of the condition.

Exceptions

JsonSQLException

at line 333
protected array select()

Selects rows that satisfy the where clause of the request.

Return Value

array The result of the selection.

at line 354
protected object|null joins(int $len)

Returns the next row resulting from the joining of tables in the query.

Parameters

int $len The number of tables

Return Value

object|null The next row or null if no more row.

at line 423
protected bool isExpression(string $string)

Checks if a string contains an expression.

Parameters

string $string The string to check

Return Value

bool true if the string contains an expression, and false if not.

at line 437
protected bool isBuiltin(string $value)

Determines if the given value is a builtin value.

Parameters

string $value The value to check

Return Value

bool true if the value is a builtin value, and false if not.

at line 448
protected array project(array $scope)

Realizes the operation of projection of result set

Parameters

array $scope The result set

Return Value

array The subset of the result set after projection

at line 494
private mixed fieldValue(stdClass $row, mixed $column)

Returns the value of a field

Parameters

stdClass $row The table row
mixed $column The table column

Return Value

mixed The value

at line 512
protected array aggregate(array $result)

Performs group by clause on the given result set, if any

Parameters

array $result The result set

Return Value

array The grouped result set

at line 581
protected void resetAggregates(array $aggregates)

Initializes aggregate functions for all columns in the query

Parameters

array $aggregates The initialized aggregate functions

Return Value

void

at line 598
protected array sort(array $result)

Sorts the result set according to the 'order by' clause.

Parameters

array $result The result set

Return Value

array The new result set

at line 630
protected array limit(array $result)

Applies the 'limit' clause on the result set

Parameters

array $result The result set

Return Value

array The new result set