class SQLite extends Connection

SQLite database connection.

Properties

protected string $name Connection name. from Connection
protected string $queryCompiler Query compiler. from Connection
protected string $queryBuilderHelper Query builder helper. from Connection
protected string $dsn Connection DSN. from Connection
protected string $username Database username. from Connection
protected string $password Database password. from Connection
protected bool $enableLog Enable the query log? from Connection
protected bool $reconnect Should we reconnect? from Connection
protected bool $usePersistentConnection Should we use a persistent connection? from Connection
protected array $options PDO options. from Connection
protected array $onConnectQueries Queries that should be executed upon connecting. from Connection
protected PDO|null $pdo PDO object. from Connection
protected int $transactionNestingLevel Transaction nesting level. from Connection
protected array $log Query log. from Connection
protected $supportsTransactionalDDL {@inheritDoc}

Methods

__construct(string $name, string $queryCompiler, string $queryBuilderHelper, array $config)

Constructor.

__clone()

Reset the log and transaction nesting level and create a new PDO instance when cloning the connection.

close()

Closes the database connection.

bool
supportsTransactionalDDL()

Does the connection support transactional DDL?

string
getName()

Returns the connection name.

getQueryBuilderHelper()

Returns a query builder helper instance.

getQueryCompiler(Query $query)

Returns a query compiler instance.

PDO
getPDO()

Returns the PDO instance.

enableLog()

Enables the query log.

disableLog()

Disables the query log.

array
getConnectionOptions()

Returns the connection options.

PDO
connect()

Creates a PDO instance.

reconnect()

Creates a new PDO instance.

bool
isAlive()

Checks if the connection is alive.

string
prepareQueryForLog(string $query, array $params)

Prepares query for logging.

log(string $query, array $params, float $start)

Adds a query to the query log.

clearLog()

Clears the query log.

array
getLog()

Returns the query log for the connection.

array
prepareQueryAndParams(string $query, array $params)

Prepare query and params.

bool
isConnectionLostAndShouldItBeReestablished()

Should we try to reestablish the connection?

bindParameter(PDOStatement $statement, int $key, mixed $value)

Binds parameter to the prepared statement.

prepareAndExecute(string $query, array $params, bool|null $success = null)

Prepares and executes a query.

bool
query(string $query, array $params = [])

Executes the query and returns TRUE on success or FALSE on failure.

int
queryAndCount(string $query, array $params = [])

Executes the query and return number of affected rows.

mixed
first(string $query, array $params = [], mixed ...$fetchMode)

Returns the first row of the result set or NULL if nothing is found.

array
all(string $query, array $params = [], mixed ...$fetchMode)

Returns an array containing all of the result set rows.

mixed
column(string $query, array $params = [])

Returns the value of the first column of the first row of the result set or NULL if nothing is found.

array
columns(string $query, array $params = [])

Returns an array containing the values of the indicated 0-indexed column.

array
pairs(string $query, array $params = [])

Returns an array where the first column is used as keys and the second as values.

yield(string $query, array $params = [], mixed ...$fetchMode)

Returns a generator that lets you iterate over the results.

builder()

Returns a query builder instance.

table(array|Closure|Raw|Subquery|string|null $table)

Returns a query builder instance where we have already chosen the table we want to query.

bool
createSavepoint()

Creates a new savepoint.

bool
rollBackSavepoint()

Rolls back to the previously created savepoint.

bool
beginTransaction()

Begin a transaction.

bool
commitTransaction()

Commits a transaction.

bool
rollBackTransaction()

Roll back a transaction.

int
getTransactionNestingLevel()

Returns the transaction nesting level.

bool
inTransaction()

Returns TRUE if we're in a transaction and FALSE if not.

mixed
transaction(Closure $queries)

Executes queries and rolls back the transaction if any of them fail.

Details

in Connection at line 158
__construct(string $name, string $queryCompiler, string $queryBuilderHelper, array $config)

Constructor.

Parameters

string $name Connection name
string $queryCompiler Query compiler
string $queryBuilderHelper Query builder helper
array $config Connection configuration

in Connection at line 194
__clone()

Reset the log and transaction nesting level and create a new PDO instance when cloning the connection.

in Connection at line 208
close()

Closes the database connection.

in Connection at line 218
bool supportsTransactionalDDL()

Does the connection support transactional DDL?

Return Value

bool

in Connection at line 228
string getName()

Returns the connection name.

Return Value

string

in Connection at line 238
HelperInterface getQueryBuilderHelper()

Returns a query builder helper instance.

Return Value

HelperInterface

in Connection at line 251
Compiler getQueryCompiler(Query $query)

Returns a query compiler instance.

Parameters

Query $query Query

Return Value

Compiler

in Connection at line 263
PDO getPDO()

Returns the PDO instance.

Return Value

PDO

in Connection at line 271
enableLog()

Enables the query log.

in Connection at line 279
disableLog()

Disables the query log.

in Connection at line 289
protected array getConnectionOptions()

Returns the connection options.

Return Value

array

in Connection at line 306
protected PDO connect()

Creates a PDO instance.

Return Value

PDO

in Connection at line 334
reconnect()

Creates a new PDO instance.

in Connection at line 344
bool isAlive()

Checks if the connection is alive.

Return Value

bool

in Connection at line 365
protected string prepareQueryForLog(string $query, array $params)

Prepares query for logging.

Parameters

string $query SQL query
array $params Query paramaters

Return Value

string

in Connection at line 401
protected log(string $query, array $params, float $start)

Adds a query to the query log.

Parameters

string $query SQL query
array $params Query parameters
float $start Start time in microseconds

in Connection at line 413
clearLog()

Clears the query log.

in Connection at line 423
array getLog()

Returns the query log for the connection.

Return Value

array

in Connection at line 435
protected array prepareQueryAndParams(string $query, array $params)

Prepare query and params.

Parameters

string $query SQL Query
array $params Query parameters

Return Value

array

in Connection at line 466
protected bool isConnectionLostAndShouldItBeReestablished()

Should we try to reestablish the connection?

Return Value

bool

in Connection at line 478
protected bindParameter(PDOStatement $statement, int $key, mixed $value)

Binds parameter to the prepared statement.

Parameters

PDOStatement $statement PDO statement
int $key Parameter key
mixed $value Parameter value

in Connection at line 518
protected PDOStatement prepareAndExecute(string $query, array $params, bool|null $success = null)

Prepares and executes a query.

Parameters

string $query SQL query
array $params Query parameters
bool|null $success &$success Was the query executed successfully?

Return Value

PDOStatement

in Connection at line 575
bool query(string $query, array $params = [])

Executes the query and returns TRUE on success or FALSE on failure.

Parameters

string $query SQL query
array $params Query parameters

Return Value

bool

in Connection at line 589
int queryAndCount(string $query, array $params = [])

Executes the query and return number of affected rows.

Parameters

string $query SQL query
array $params Query parameters

Return Value

int

in Connection at line 602
mixed first(string $query, array $params = [], mixed ...$fetchMode)

Returns the first row of the result set or NULL if nothing is found.

Parameters

string $query SQL query
array $params Query params
mixed ...$fetchMode Fetch mode

Return Value

mixed

in Connection at line 622
array all(string $query, array $params = [], mixed ...$fetchMode)

Returns an array containing all of the result set rows.

Parameters

string $query SQL query
array $params Query parameters
mixed ...$fetchMode Fetch mode

Return Value

array

in Connection at line 634
mixed column(string $query, array $params = [])

Returns the value of the first column of the first row of the result set or NULL if nothing is found.

Parameters

string $query SQL query
array $params Query parameters

Return Value

mixed

in Connection at line 646
array columns(string $query, array $params = [])

Returns an array containing the values of the indicated 0-indexed column.

Parameters

string $query SQL query
array $params Query parameters

Return Value

array

in Connection at line 658
array pairs(string $query, array $params = [])

Returns an array where the first column is used as keys and the second as values.

Parameters

string $query SQL query
array $params Query parameters

Return Value

array

in Connection at line 671
Generator yield(string $query, array $params = [], mixed ...$fetchMode)

Returns a generator that lets you iterate over the results.

Parameters

string $query SQL query
array $params Query params
mixed ...$fetchMode Fetch mode

Return Value

Generator

in Connection at line 698
Query builder()

Returns a query builder instance.

Return Value

Query

in Connection at line 709
Query table(array|Closure|Raw|Subquery|string|null $table)

Returns a query builder instance where we have already chosen the table we want to query.

Parameters

array|Closure|Raw|Subquery|string|null $table Database table or subquery

Return Value

Query

in Connection at line 719
protected bool createSavepoint()

Creates a new savepoint.

Return Value

bool

in Connection at line 729
protected bool rollBackSavepoint()

Rolls back to the previously created savepoint.

Return Value

bool

in Connection at line 739
bool beginTransaction()

Begin a transaction.

Return Value

bool

in Connection at line 754
bool commitTransaction()

Commits a transaction.

Return Value

bool

in Connection at line 769
bool rollBackTransaction()

Roll back a transaction.

Return Value

bool

in Connection at line 795
int getTransactionNestingLevel()

Returns the transaction nesting level.

Return Value

int

in Connection at line 805
bool inTransaction()

Returns TRUE if we're in a transaction and FALSE if not.

Return Value

bool

in Connection at line 816
mixed transaction(Closure $queries)

Executes queries and rolls back the transaction if any of them fail.

Parameters

Closure $queries Queries

Return Value

mixed