class PDOStatementHandle (View source)

A handle to a PDOStatement, with cached column metadata, and type conversion

Column metadata can't be fetched from a native PDOStatement after multiple calls in some DB backends, so we wrap in this handle object, which also takes care of tidying up content types to keep in line with the SilverStripe 4.4+ type expectations.

Methods

__construct(PDOStatement $statement)

Create a new handle.

array
typeCorrectedFetchAll()

Fetch a record form the statement with its type data corrected Returns data as an array of maps

bool
closeCursor()

Closes the cursor, enabling the statement to be executed again (PDOStatement::closeCursor)

string
errorCode()

Fetch the SQLSTATE associated with the last operation on the statement handle (PDOStatement::errorCode)

array
errorInfo()

Fetch extended error information associated with the last operation on the statement handle (PDOStatement::errorInfo)

int
rowCount()

Returns the number of rows affected by the last SQL statement (PDOStatement::rowCount)

bool
execute(array $parameters)

Executes a prepared statement (PDOStatement::execute)

getPDOStatement()

Return the PDOStatement that this object provides a handle to

Details

__construct(PDOStatement $statement)

Create a new handle.

Parameters

PDOStatement $statement

The statement to provide a handle to

array typeCorrectedFetchAll()

Fetch a record form the statement with its type data corrected Returns data as an array of maps

Return Value

array

bool closeCursor()

Closes the cursor, enabling the statement to be executed again (PDOStatement::closeCursor)

Return Value

bool

Returns true on success

string errorCode()

Fetch the SQLSTATE associated with the last operation on the statement handle (PDOStatement::errorCode)

Return Value

string

array errorInfo()

Fetch extended error information associated with the last operation on the statement handle (PDOStatement::errorInfo)

Return Value

array

int rowCount()

Returns the number of rows affected by the last SQL statement (PDOStatement::rowCount)

Return Value

int

bool execute(array $parameters)

Executes a prepared statement (PDOStatement::execute)

Parameters

array $parameters

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

Return Value

bool

Returns true on success

PDOStatement getPDOStatement()

Return the PDOStatement that this object provides a handle to

Return Value

PDOStatement