PreparedStatement
extends Statement
in package
A PDOStatment subclass that logs prepared statements.
Logs the execution time and executed query to the connected Database.
Table of Contents
- $database : Database
- Direct link to the Database object that created the prepared statement.
- $params : array<string|int, mixed>
- The bound parameters via bindParam/bindValue.
- bindParam() : bool
- Binds a parameter to the specified variable name.
- bindValue() : bool
- Bind a column to a PHP variable.
- count() : int
- Return the number of rows in the result (Slow on SQlite databases).
- execute() : bool
- Executes a prepared statement.
- __construct() : mixed
- Constructor (called from within PDO->prepare() via \PDO::ATTR_STATEMENT_CLASS).
- interpolate() : string
- Replaces any parameter placeholders in a query with the value of that parameter. Useful for debugging. Assumes anonymous parameters from $params are are in the same order as specified in $query.
Properties
$database
Direct link to the Database object that created the prepared statement.
private
Database
$database
$params
The bound parameters via bindParam/bindValue.
private
array<string|int, mixed>
$params
= []
Methods
bindParam()
Binds a parameter to the specified variable name.
public
bindParam(mixed $parameter, mixed &$variable[, int $data_type = null ][, int $length = null ][, mixed $driver_options = null ]) : bool
Parameters
- $parameter : mixed
- $variable : mixed
- $data_type : int = null
- $length : int = null
- $driver_options : mixed = null
Tags
Return values
bool —bindValue()
Bind a column to a PHP variable.
public
bindValue(mixed $parameter, mixed $value[, mixed $data_type = null ]) : bool
Parameters
- $parameter : mixed
- $value : mixed
- $data_type : mixed = null
Tags
Return values
bool —count()
Return the number of rows in the result (Slow on SQlite databases).
public
count() : int
Return values
int —execute()
Executes a prepared statement.
public
execute([array<string|int, mixed> $input_parameters = [] ]) : bool
Parameters
- $input_parameters : array<string|int, mixed> = []
-
(optional)
Tags
Return values
bool —__construct()
Constructor (called from within PDO->prepare() via \PDO::ATTR_STATEMENT_CLASS).
private
__construct(Database $database) : mixed
Parameters
- $database : Database
Tags
Return values
mixed —interpolate()
Replaces any parameter placeholders in a query with the value of that parameter. Useful for debugging. Assumes anonymous parameters from $params are are in the same order as specified in $query.
private
interpolate(string $query, array<string|int, mixed> $params) : string
Parameters
- $query : string
-
The sql query with parameter placeholders
- $params : array<string|int, mixed>
-
The array of substitution parameters
Return values
string —The interpolated query