Documentation

Statement

Driver-level statement

Table of Contents

Methods

bindParam()  : bool
Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question mark placeholder in the SQL statement that was use to prepare the statement. Unlike {@see bindValue()}, the variable is bound as a reference and will only be evaluated at the time that PDOStatement->execute() is called.
bindValue()  : bool
Binds a value to a corresponding named (not supported by mysqli driver, see comment below) or positional placeholder in the SQL statement that was used to prepare the statement.
execute()  : Result
Executes a prepared statement

Methods

bindParam()

Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question mark placeholder in the SQL statement that was use to prepare the statement. Unlike {@see bindValue()}, the variable is bound as a reference and will only be evaluated at the time that PDOStatement->execute() is called.

public bindParam(string|int $param, mixed &$variable[, int $type = ParameterType::STRING ][, int|null $length = null ]) : bool

As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(), fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.

Most parameters are input parameters, that is, parameters that are used in a read-only fashion to build up the query. Some drivers support the invocation of stored procedures that return data as output parameters, and some also as input/output parameters that both send in data and are updated to receive it.

Parameters
$param : string|int

Parameter identifier. For a prepared statement using named placeholders, this will be a parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the 1-indexed position of the parameter.

$variable : mixed

Name of the PHP variable to bind to the SQL statement parameter.

$type : int = ParameterType::STRING

Explicit data type for the parameter using the ParameterType constants.

$length : int|null = null

You must specify maxlength when using an OUT bind so that PHP allocates enough memory to hold the returned value.

Tags
deprecated

Use bindValue() instead.

throws
Exception
Return values
bool

TRUE on success or FALSE on failure.

bindValue()

Binds a value to a corresponding named (not supported by mysqli driver, see comment below) or positional placeholder in the SQL statement that was used to prepare the statement.

public bindValue(string|int $param, mixed $value[, int $type = ParameterType::STRING ]) : bool

As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(), fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.

Parameters
$param : string|int

Parameter identifier. For a prepared statement using named placeholders, this will be a parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the 1-indexed position of the parameter.

$value : mixed

The value to bind to the parameter.

$type : int = ParameterType::STRING

Explicit data type for the parameter using the ParameterType constants.

Tags
throws
Exception
Return values
bool

TRUE on success or FALSE on failure.

execute()

Executes a prepared statement

public execute([array<string|int, mixed>|null $params = null ]) : Result

If the prepared statement included parameter markers, you must either: call bindParam() to bind PHP variables to the parameter markers: bound variables pass their value as input and receive the output value, if any, of their associated parameter markers or pass an array of input-only parameter values.

Parameters
$params : array<string|int, mixed>|null = null

A numeric array of values with as many elements as there are bound parameters in the SQL statement being executed.

Tags
throws
Exception
Return values
Result

        
On this page

Search results