Class SqliteStatement
Statement class meant to be used by an Sqlite driver
Constants
- 
          
          
stringFETCH_TYPE_ASSOC ¶'assoc'Maps to PDO::FETCH_ASSOC.
 - 
          
          
stringFETCH_TYPE_NUM ¶'num'Maps to PDO::FETCH_NUM.
 - 
          
          
stringFETCH_TYPE_OBJ ¶'obj'Maps to PDO::FETCH_OBJ.
 - 
          
          
array<string, int>MODE_NAME_MAP ¶[self::FETCH_TYPE_ASSOC => PDO::FETCH_ASSOC, self::FETCH_TYPE_NUM => PDO::FETCH_NUM, self::FETCH_TYPE_OBJ => PDO::FETCH_OBJ] 
Property Summary
- 
        $_driver protected
Cake\Database\Driver - 
        $affectedRows protected
int|null - 
        $params protected
array<mixed>Cached bound parameters used for logging
 
Method Summary
- 
          
__construct() public
 - 
          
bind() public
Binds a set of values to statement object with corresponding type.
 - 
          
bindValue() public
Assign 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.
 - 
          
cast() protected
Converts a give value to a suitable database value based on type and return relevant internal statement type.
 - 
          
closeCursor() public
Closes the cursor, enabling the statement to be executed again.
 - 
          
columnCount() public
Returns the number of columns in the result set.
 - 
          
convertMode() protected
Converts mode name to PDO constant.
 - 
          
errorCode() public
Fetch the SQLSTATE associated with the last operation on the statement handle.
 - 
          
errorInfo() public
Fetch extended error information associated with the last operation on the statement handle.
 - 
          
execute() public
Executes 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() public
Fetches the next row from a result set and converts fields to types based on TypeMap.
 - 
          
fetchAll() public
Fetches the remaining rows from a result set and converts fields to types based on TypeMap.
 - 
          
fetchAssoc() public
Fetches the next row from a result set using PDO::FETCH_ASSOC and converts fields to types based on TypeMap.
 - 
          
fetchColumn() public
Fetches the next row from a result set using PDO::FETCH_NUM and converts fields to types based on TypeMap.
 - 
          
getBoundParams() public
Get the bound params.
 - 
          
getIterator() public
Get the inner iterator
 - 
          
lastInsertId() public
Returns the latest primary inserted using this statement.
 - 
          
performBind() protected
 - 
          
queryString() public
Returns prepared query string stored in PDOStatement.
 - 
          
rowCount() public
Returns the number of rows affected by the last SQL statement.
 
Method Detail
__construct() ¶ public
__construct(PDOStatement $statement, Cake\Database\Driver $driver, array<Closure> $resultDecorators = [])
      Parameters
- 
                
PDOStatement$statement PDO statement
- 
                
Cake\Database\Driver$driver Database driver
- 
                
array<Closure>$resultDecorators optional Results decorators
bind() ¶ public
bind(array $params, array $types): void
      Binds a set of values to statement object with corresponding type.
Parameters
- 
                
array$params - 
                
array$types 
Returns
voidbindValue() ¶ public
bindValue(string|int $column, mixed $value, string|int|null $type = 'string'): void
      Assign 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 - 
                
mixed$value - 
                
string|int|null$type optional 
Returns
voidcast() ¶ protected
cast(mixed $value, Cake\Database\TypeInterface|string|int $type = 'string'): array
      Converts a give value to a suitable database value based on type and return relevant internal statement type.
Parameters
- 
                
mixed$value The value to cast.
- 
                
Cake\Database\TypeInterface|string|int$type optional The type name or type instance to use.
Returns
arrayList containing converted value and internal type.
closeCursor() ¶ public
closeCursor(): void
      Closes the cursor, enabling the statement to be executed again.
This behaves the same as PDOStatement::closeCursor().
Returns
voidcolumnCount() ¶ public
columnCount(): int
      Returns the number of columns in the result set.
This behaves the same as PDOStatement::columnCount().
Returns
intconvertMode() ¶ protected
convertMode(string|int $mode): int
      Converts mode name to PDO constant.
Parameters
- 
                
string|int$mode Mode name or PDO constant
Returns
intThrows
InvalidArgumentExceptionerrorCode() ¶ public
errorCode(): string
      Fetch the SQLSTATE associated with the last operation on the statement handle.
This behaves the same as PDOStatement::errorCode().
Returns
stringerrorInfo() ¶ public
errorInfo(): array
      Fetch extended error information associated with the last operation on the statement handle.
This behaves the same as PDOStatement::errorInfo().
Returns
arrayexecute() ¶ public
execute(array|null $params = null): bool
      Executes 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 
Returns
boolfetch() ¶ public
fetch(string|int $mode = PDO::FETCH_NUM): mixed
      Fetches 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 
Returns
mixedfetchAll() ¶ public
fetchAll(string|int $mode = PDO::FETCH_NUM): array
      Fetches 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 
Returns
arrayfetchAssoc() ¶ public
fetchAssoc(): array
      Fetches 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): mixed
      Fetches 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 
Returns
mixedlastInsertId() ¶ public
lastInsertId(string|null $table = null, string|null $column = null): string|int
      Returns the latest primary inserted using this statement.
Parameters
- 
                
string|null$table optional - 
                
string|null$column optional 
Returns
string|intperformBind() ¶ protected
performBind(string|int $column, mixed $value, int $type): void
      Parameters
- 
                
string|int$column - 
                
mixed$value - 
                
int$type 
Returns
voidqueryString() ¶ public
queryString(): string
      Returns prepared query string stored in PDOStatement.
Returns
stringrowCount() ¶ public
rowCount(): int
      Returns the number of rows affected by the last SQL statement.
This behaves the same as PDOStatement::rowCount().
Returns
int