Interface StatementInterface
Constants
Method Summary
- 
          bind() publicBinds a set of values to statement object with corresponding type. 
- 
          bindValue() publicAssign a value to a positional or named variable in prepared query. If using positional variables you need to start with index one, if using named params then just use the name in any order. 
- 
          closeCursor() publicCloses the cursor, enabling the statement to be executed again. 
- 
          columnCount() publicReturns the number of columns in the result set. 
- 
          errorCode() publicFetch the SQLSTATE associated with the last operation on the statement handle. 
- 
          errorInfo() publicFetch extended error information associated with the last operation on the statement handle. 
- 
          execute() publicExecutes the statement by sending the SQL query to the database. It can optionally take an array or arguments to be bound to the query variables. Please note that binding parameters from this method will not perform any custom type conversion as it would normally happen when calling bindValue.
- 
          fetch() publicFetches the next row from a result set and converts fields to types based on TypeMap. 
- 
          fetchAll() publicFetches the remaining rows from a result set and converts fields to types based on TypeMap. 
- 
          fetchAssoc() publicFetches the next row from a result set using PDO::FETCH_ASSOC and converts fields to types based on TypeMap. 
- 
          fetchColumn() publicFetches the next row from a result set using PDO::FETCH_NUM and converts fields to types based on TypeMap. 
- 
          getBoundParams() publicGet the bound params. 
- 
          lastInsertId() publicReturns the latest primary inserted using this statement. 
- 
          queryString() publicReturns prepared query string. 
- 
          rowCount() publicReturns the number of rows affected by the last SQL statement. 
Method Detail
bind() ¶ public
bind(array $params, array $types): voidBinds a set of values to statement object with corresponding type.
Parameters
- 
                array$params
- list of values to be bound 
- 
                array$types
- list of types to be used, keys should match those in $params 
Returns
voidbindValue() ¶ public
bindValue(string|int $column, mixed $value, string|int|null $type = 'string'): voidAssign a value to a positional or named variable in prepared query. If using positional variables you need to start with index one, if using named params then just use the name in any order.
It is not allowed to combine positional and named variables in the same statement.
Examples:
$statement->bindValue(1, 'a title');
$statement->bindValue('active', true, 'boolean');
$statement->bindValue(5, new \DateTime(), 'date');Parameters
- 
                string|int$column
- name or param position to be bound 
- 
                mixed$value
- The value to bind to variable in query 
- 
                string|int|null$type optional
- name of configured Type class 
Returns
voidcloseCursor() ¶ public
closeCursor(): voidCloses the cursor, enabling the statement to be executed again.
This behaves the same as PDOStatement::closeCursor().
Returns
voidcolumnCount() ¶ public
columnCount(): intReturns the number of columns in the result set.
This behaves the same as PDOStatement::columnCount().
Returns
intLinks
errorCode() ¶ public
errorCode(): stringFetch the SQLSTATE associated with the last operation on the statement handle.
This behaves the same as PDOStatement::errorCode().
Returns
stringLinks
errorInfo() ¶ public
errorInfo(): arrayFetch extended error information associated with the last operation on the statement handle.
This behaves the same as PDOStatement::errorInfo().
Returns
arrayLinks
execute() ¶ public
execute(array|null $params = null): boolExecutes the statement by sending the SQL query to the database. It can optionally
take an array or arguments to be bound to the query variables. Please note
that binding parameters from this method will not perform any custom type conversion
as it would normally happen when calling bindValue.
Parameters
- 
                array|null$params optional
- list of values to be bound to query 
Returns
booltrue on success, false otherwise
fetch() ¶ public
fetch(string|int $mode = PDO::FETCH_NUM): mixedFetches the next row from a result set and converts fields to types based on TypeMap.
This behaves the same as PDOStatement::fetch().
Parameters
- 
                string|int$mode optional
- PDO::FETCH_* constant or fetch mode name. Valid names are 'assoc', 'num' or 'obj'. 
Returns
mixedThrows
InvalidArgumentExceptionLinks
fetchAll() ¶ public
fetchAll(string|int $mode = PDO::FETCH_NUM): arrayFetches the remaining rows from a result set and converts fields to types based on TypeMap.
This behaves the same as PDOStatement::fetchAll().
Parameters
- 
                string|int$mode optional
- PDO::FETCH_* constant or fetch mode name. Valid names are 'assoc', 'num' or 'obj'. 
Returns
arrayThrows
InvalidArgumentExceptionLinks
fetchAssoc() ¶ public
fetchAssoc(): arrayFetches the next row from a result set using PDO::FETCH_ASSOC and converts fields to types based on TypeMap.
This behaves the same as PDOStatement::fetch() except an
empty array is returned instead of false.
Returns
arrayfetchColumn() ¶ public
fetchColumn(int $position): mixedFetches the next row from a result set using PDO::FETCH_NUM and converts fields to types based on TypeMap.
This behaves the same as PDOStatement::fetch() except only
a specific column from the row is returned.
Parameters
- 
                int$position
- Column index in result row. 
Returns
mixedlastInsertId() ¶ public
lastInsertId(string|null $table = null, string|null $column = null): string|intReturns the latest primary inserted using this statement.
Parameters
- 
                string|null$table optional
- table name or sequence to get last insert value from 
- 
                string|null$column optional
- the name of the column representing the primary key 
Returns
string|introwCount() ¶ public
rowCount(): intReturns the number of rows affected by the last SQL statement.
This behaves the same as PDOStatement::rowCount().
Returns
int