class OCI8Statement implements IteratorAggregate, Statement (View source)

The OCI8 implementation of the Statement interface.

Properties

protected resource $_dbh
protected resource $_sth
protected OCI8Connection $_conn
static protected string $_PARAM
static protected array $fetchModeMap
protected int $_defaultFetchMode
protected array $_paramMap

Methods

__construct(resource $dbh, string $statement, OCI8Connection $conn)

Creates a new OCI8Statement that uses the given connection handle and SQL statement.

static array
convertPositionalToNamedPlaceholders(string $statement)

Converts positional (?) into named placeholders (:param).

bool
bindValue(mixed $param, mixed $value, int $type = ParameterType::STRING)

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.

bool
bindParam(mixed $column, mixed $variable, int|null $type = ParameterType::STRING, int|null $length = null)

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 PDOStatement->bindValue(), the variable is bound as a reference and will only be evaluated at the time that PDOStatement->execute() is called.

bool
closeCursor()

Closes the cursor, enabling the statement to be executed again.

int
columnCount()

Returns the number of columns in the result set

string|int|bool
errorCode()

Fetches the SQLSTATE associated with the last operation on the statement handle.

array
errorInfo()

Fetches extended error information associated with the last operation on the statement handle.

bool
execute(array|null $params = null)

Executes a prepared statement

bool
setFetchMode(int $fetchMode, mixed $arg2 = null, mixed $arg3 = null)

Sets the fetch mode to use while iterating this statement.

getIterator()

{@inheritdoc}

mixed
fetch(int|null $fetchMode = null, int $cursorOrientation = \PDO::FETCH_ORI_NEXT, int $cursorOffset = 0)

Returns the next row of a result set.

array
fetchAll(int|null $fetchMode = null, int|null $fetchArgument = null, array|null $ctorArgs = null)

Returns an array containing all of the result set rows.

string|boolean
fetchColumn(int $columnIndex = 0)

Returns a single column from the next row of a result set or FALSE if there are no more rows.

int
rowCount()

Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding object.

Details

__construct(resource $dbh, string $statement, OCI8Connection $conn)

Creates a new OCI8Statement that uses the given connection handle and SQL statement.

Parameters

resource $dbh The connection handle.
string $statement The SQL statement.
OCI8Connection $conn

static array convertPositionalToNamedPlaceholders(string $statement)

Converts positional (?) into named placeholders (:param).

Oracle does not support positional parameters, hence this method converts all positional parameters into artificially named parameters. Note that this conversion is not perfect. All question marks (?) in the original statement are treated as placeholders and converted to a named parameter.

The algorithm uses a state machine with two possible states: InLiteral and NotInLiteral. Question marks inside literal strings are therefore handled correctly by this method. This comes at a cost, the whole sql statement has to be looped over.

Parameters

string $statement The SQL statement to convert.

Return Value

array [0] => the statement value (string), [1] => the paramMap value (array).

Exceptions

OCI8Exception

bool bindValue(mixed $param, mixed $value, int $type = ParameterType::STRING)

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.

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

mixed $param 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.
mixed $value The value to bind to the parameter.
int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType} constants.

Return Value

bool TRUE on success or FALSE on failure.

bool bindParam(mixed $column, mixed $variable, int|null $type = ParameterType::STRING, int|null $length = null)

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 PDOStatement->bindValue(), the variable is bound as a reference and will only be evaluated at the time that PDOStatement->execute() is called.

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

mixed $column 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.
mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
int|null $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType} constants. To return an INOUT parameter from a stored procedure, use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
int|null $length You must specify maxlength when using an OUT bind so that PHP allocates enough memory to hold the returned value.

Return Value

bool TRUE on success or FALSE on failure.

bool closeCursor()

Closes the cursor, enabling the statement to be executed again.

Return Value

bool TRUE on success or FALSE on failure.

int columnCount()

Returns the number of columns in the result set

Return Value

int The number of columns in the result set represented by the PDOStatement object. If there is no result set, this method should return 0.

string|int|bool errorCode()

Fetches the SQLSTATE associated with the last operation on the statement handle.

Return Value

string|int|bool The error code string.

array errorInfo()

Fetches extended error information associated with the last operation on the statement handle.

Return Value

array The error info array.

bool execute(array|null $params = null)

Executes a prepared statement

If the prepared statement included parameter markers, you must either: call PDOStatement->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

array|null $params An array of values with as many elements as there are bound parameters in the SQL statement being executed.

Return Value

bool TRUE on success or FALSE on failure.

bool setFetchMode(int $fetchMode, mixed $arg2 = null, mixed $arg3 = null)

Sets the fetch mode to use while iterating this statement.

Parameters

int $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
mixed $arg2
mixed $arg3

Return Value

bool

getIterator()

{@inheritdoc}

mixed fetch(int|null $fetchMode = null, int $cursorOrientation = \PDO::FETCH_ORI_NEXT, int $cursorOffset = 0)

Returns the next row of a result set.

Parameters

int|null $fetchMode Controls how the next row will be returned to the caller. The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
int $cursorOrientation For a ResultStatement object representing a scrollable cursor, this value determines which row will be returned to the caller. This value must be one of the \PDO::FETCH_ORI_* constants, defaulting to \PDO::FETCH_ORI_NEXT. To request a scrollable cursor for your ResultStatement object, you must set the \PDO::ATTR_CURSOR attribute to \PDO::CURSOR_SCROLL when you prepare the SQL statement with \PDO::prepare().
int $cursorOffset For a ResultStatement object representing a scrollable cursor for which the cursorOrientation parameter is set to \PDO::FETCH_ORI_ABS, this value specifies the absolute number of the row in the result set that shall be fetched. For a ResultStatement object representing a scrollable cursor for which the cursorOrientation parameter is set to \PDO::FETCH_ORI_REL, this value specifies the row to fetch relative to the cursor position before ResultStatement::fetch() was called.

Return Value

mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is returned on failure.

array fetchAll(int|null $fetchMode = null, int|null $fetchArgument = null, array|null $ctorArgs = null)

Returns an array containing all of the result set rows.

Parameters

int|null $fetchMode Controls how the next row will be returned to the caller. The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter: * {@link \Doctrine\DBAL\FetchMode::COLUMN}: Returns the indicated 0-indexed column. * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}: Returns instances of the specified class, mapping the columns of each row to named properties in the class. * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's columns as parameters in the call.
array|null $ctorArgs Controls how the next row will be returned to the caller. The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.

Return Value

array

string|boolean fetchColumn(int $columnIndex = 0)

Returns a single column from the next row of a result set or FALSE if there are no more rows.

Parameters

int $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no value is supplied, PDOStatement->fetchColumn() fetches the first column.

Return Value

string|boolean A single column in the next row of a result set, or FALSE if there are no more rows.

int rowCount()

Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding object.

If the last SQL statement executed by the associated Statement object was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.

Return Value

int The number of rows.