Index Documentation

SqliteConnection
in package
implements DbConnection

Represents a client for an SQLite database.

Table of Contents

Interfaces

DbConnection
Represents a connection to a database service.

Constants

ALTER_TABLE  = \SQLite3::ALTER_TABLE
ALTER TABLE authorizer.
ANALYZE  = \SQLite3::ANALYZE
ANALYZE authorizer.
ATTACH  = \SQLite3::ATTACH
ATTACH authorizer.
CREATE_INDEX  = \SQLite3::CREATE_INDEX
CREATE INDEX authorizer.
CREATE_TABLE  = \SQLite3::CREATE_TABLE
CREATE TABLE authorizer.
CREATE_TEMP_INDEX  = \SQLite3::CREATE_TEMP_INDEX
CREATE TEMP INDEX authorizer.
CREATE_TEMP_TABLE  = \SQLite3::CREATE_TEMP_TABLE
CREATE TEMP TABLE authorizer.
CREATE_TEMP_TRIGGER  = \SQLite3::CREATE_TEMP_TRIGGER
CREATE TEMP TRIGGER authorizer.
CREATE_TEMP_VIEW  = \SQLite3::CREATE_TEMP_VIEW
CREATE TEMP VIEW authorizer.
CREATE_TRIGGER  = \SQLite3::CREATE_TRIGGER
CREATE TRIGGER authorizer.
CREATE_VIEW  = \SQLite3::CREATE_VIEW
CREATE VIEW authorizer.
CREATE_VTABLE  = \SQLite3::CREATE_VTABLE
CREATE VTABLE authorizer.
DELETE  = \SQLite3::DELETE
DELETE authorizer.
DENY  = \SQLite3::DENY
DENY authorization status.
DETACH  = \SQLite3::DETACH
DETACH authorizer.
DETERMINISTIC  = SQLITE3_DETERMINISTIC
DETERMINISTIC flag for SQLite registered functions.
DROP_INDEX  = \SQLite3::DROP_INDEX
DROP INDEX authorizer.
DROP_TABLE  = \SQLite3::DROP_TABLE
DROP TABLE authorizer.
DROP_TEMP_INDEX  = \SQLite3::DROP_TEMP_INDEX
DROP TEMP INDEX authorizer.
DROP_TEMP_TABLE  = \SQLite3::DROP_TEMP_TABLE
DROP TEMP TABLE authorizer.
DROP_TEMP_TRIGGER  = \SQLite3::DROP_TEMP_TRIGGER
DROP TEMP TRIGGER authorizer.
DROP_TEMP_VIEW  = \SQLite3::DROP_TEMP_VIEW
DROP TEMP VIEW authorizer.
DROP_TRIGGER  = \SQLite3::DROP_TRIGGER
DROP TRIGGER authorizer.
DROP_VIEW  = \SQLite3::DROP_VIEW
DROP VIEW authorizer.
DROP_VTABLE  = \SQLite3::DROP_VTABLE
DROP VTABLE authorizer.
FUNCTION  = \SQLite3::FUNCTION
FUNCTION authorizer.
IGNORE  = \SQLite3::IGNORE
IGNORE authorization status.
INSERT  = \SQLite3::INSERT
INSERT authorizer.
OK  = \SQLite3::OK
OK authorization status.
PRAGMA  = \SQLite3::PRAGMA
PRAGMA authorizer.
READ  = \SQLite3::READ
READ authorizer.
RECURSIVE  = \SQLite3::RECURSIVE
RECURSIVE authorizer.
REINDEX  = \SQLite3::REINDEX
REINDEX authorizer.
SAVEPOINT  = \SQLite3::SAVEPOINT
SAVEPOINT authorizer.
SELECT  = \SQLite3::SELECT
SELECT authorizer.
TRANSACTION  = \SQLite3::TRANSACTION
TRANSACTION authorizer.
UPDATE  = \SQLite3::UPDATE
UPDATE authorizer.

Methods

__construct()  : SqliteConnection
Creates a new SQLite client.
__destruct()  : mixed
beginTransaction()  : DbTransaction
Begins a transaction.
createAggregate()  : bool
Registers a PHP function for use as an SQL aggregate function.
createCollation()  : bool
Registers a PHP function for use as an SQL collating function.
createFunction()  : bool
Register a PHP function for use as an SQL scalar function.
execute()  : int|string
Executes a statement and returns how many rows are affected.
executeThrow()  : void
Tries to execute a query but throws an exception if it fails.
getAffectedRows()  : int|string
Gets the number of rows affected by the last operation.
getBlobStream()  : resource
Opens a BLOB field as a resource.
getLastErrorCode()  : int
Gets the last error code.
getLastErrorString()  : string
Gets the last error string.
getLastInsertId()  : int|string
Returns the ID of the last inserted row.
prepare()  : DbStatement
Prepares a statement for execution and returns a database statement instance.
query()  : DbResult
Executes a statement and returns a database result instance.
setAuthorizer()  : bool
Sets a callback to be used as an authorizer to limit what statements can do.
throwLastError()  : never
Throws the last error as a RuntimeException.

Constants

ALTER_TABLE

ALTER TABLE authorizer.

public int ALTER_TABLE = \SQLite3::ALTER_TABLE

Second parameter will be the name of the database. Third parameter will be the name of the table.

ANALYZE

ANALYZE authorizer.

public int ANALYZE = \SQLite3::ANALYZE

Second parameter will be the name of the table.

ATTACH

ATTACH authorizer.

public int ATTACH = \SQLite3::ATTACH

Second parameter will be the filename.

CREATE_INDEX

CREATE INDEX authorizer.

public int CREATE_INDEX = \SQLite3::CREATE_INDEX

Second parameter will be the name of the index. Third parameter will be the name of the table.

CREATE_TABLE

CREATE TABLE authorizer.

public int CREATE_TABLE = \SQLite3::CREATE_TABLE

Second parameter will be the name of the table.

CREATE_TEMP_INDEX

CREATE TEMP INDEX authorizer.

public int CREATE_TEMP_INDEX = \SQLite3::CREATE_TEMP_INDEX

Second parameter will be the name of the index. Third parameter will be the name of the table.

CREATE_TEMP_TABLE

CREATE TEMP TABLE authorizer.

public int CREATE_TEMP_TABLE = \SQLite3::CREATE_TEMP_TABLE

Second parameter will be the name of the table.

CREATE_TEMP_TRIGGER

CREATE TEMP TRIGGER authorizer.

public int CREATE_TEMP_TRIGGER = \SQLite3::CREATE_TEMP_TRIGGER

Second parameter will be the name of the trigger. Third parameter will be the name of the table.

CREATE_TEMP_VIEW

CREATE TEMP VIEW authorizer.

public int CREATE_TEMP_VIEW = \SQLite3::CREATE_TEMP_VIEW

Second parameter will be the name of the view.

CREATE_TRIGGER

CREATE TRIGGER authorizer.

public int CREATE_TRIGGER = \SQLite3::CREATE_TRIGGER

Second parameter will be the name of the trigger. Third parameter will be the name of the table.

CREATE_VIEW

CREATE VIEW authorizer.

public int CREATE_VIEW = \SQLite3::CREATE_VIEW

Second parameter will be the name of the view.

CREATE_VTABLE

CREATE VTABLE authorizer.

public int CREATE_VTABLE = \SQLite3::CREATE_VTABLE

Second parameter will be the name of the table. Third parameter will be the name of the module.

DELETE

DELETE authorizer.

public int DELETE = \SQLite3::DELETE

Second parameter will be the name of the table.

DETACH

DETACH authorizer.

public int DETACH = \SQLite3::DETACH

Second parameter will be the name of the database.

DETERMINISTIC

DETERMINISTIC flag for SQLite registered functions.

public int DETERMINISTIC = SQLITE3_DETERMINISTIC

When specified the function will always return the same result given the same inputs within a single SQL statement.

DROP_INDEX

DROP INDEX authorizer.

public int DROP_INDEX = \SQLite3::DROP_INDEX

Second parameter will be the name of the index. Third parameter will be the name of the table.

DROP_TABLE

DROP TABLE authorizer.

public int DROP_TABLE = \SQLite3::DROP_TABLE

Second parameter will be the name of the table.

DROP_TEMP_INDEX

DROP TEMP INDEX authorizer.

public int DROP_TEMP_INDEX = \SQLite3::DROP_TEMP_INDEX

Second parameter will be the name of the index. Third parameter will be the name of the table.

DROP_TEMP_TABLE

DROP TEMP TABLE authorizer.

public int DROP_TEMP_TABLE = \SQLite3::DROP_TEMP_TABLE

Second parameter will be the name of the table.

DROP_TEMP_TRIGGER

DROP TEMP TRIGGER authorizer.

public int DROP_TEMP_TRIGGER = \SQLite3::DROP_TEMP_TRIGGER

Second parameter will be the name of the trigger. Third parameter will be the name of the table.

DROP_TEMP_VIEW

DROP TEMP VIEW authorizer.

public int DROP_TEMP_VIEW = \SQLite3::DROP_TEMP_VIEW

Second parameter will be the name of the view.

DROP_TRIGGER

DROP TRIGGER authorizer.

public int DROP_TRIGGER = \SQLite3::DROP_TRIGGER

Second parameter will be the name of the trigger. Third parameter will be the name of the table.

DROP_VIEW

DROP VIEW authorizer.

public int DROP_VIEW = \SQLite3::DROP_VIEW

Second parameter will be the name of the view.

DROP_VTABLE

DROP VTABLE authorizer.

public int DROP_VTABLE = \SQLite3::DROP_VTABLE

Second parameter will be the name of the table. Third parameter will be the name of the module.

FUNCTION

FUNCTION authorizer.

public int FUNCTION = \SQLite3::FUNCTION

Third parameter will be the name of the function.

IGNORE

IGNORE authorization status.

public int IGNORE = \SQLite3::IGNORE

INSERT

INSERT authorizer.

public int INSERT = \SQLite3::INSERT

Second parameter will be the name of the table.

PRAGMA

PRAGMA authorizer.

public int PRAGMA = \SQLite3::PRAGMA

Second parameter will be the name of the pragma. Third parameter may be the first argument passed to the pragma.

READ

READ authorizer.

public int READ = \SQLite3::READ

Second parameter will be the name of the table. Third parameter will be the name of the column.

RECURSIVE

RECURSIVE authorizer.

public int RECURSIVE = \SQLite3::RECURSIVE

REINDEX

REINDEX authorizer.

public int REINDEX = \SQLite3::REINDEX

Second parameter will be the name of the index.

SAVEPOINT

SAVEPOINT authorizer.

public int SAVEPOINT = \SQLite3::SAVEPOINT

Second parameter will be the operation. Third parameter will be the name of the savepoint.

TRANSACTION

TRANSACTION authorizer.

public int TRANSACTION = \SQLite3::TRANSACTION

Second parameter will be the operation.

UPDATE

UPDATE authorizer.

public int UPDATE = \SQLite3::UPDATE

Second parameter will be the name of the table. Third parameter will be the name of the column.

Methods

createAggregate()

Registers a PHP function for use as an SQL aggregate function.

public createAggregate(string $name, callable $stepCallback, callable $finalCallback[, int $argCount = -1 ]) : bool
Parameters
$name : string

Name of the SQL aggregate.

$stepCallback : callable

Callback function to be called for each row of the result set. Definition: step(mixed $context, int $rowNumber, mixed $value, mixed ...$values): mixed

$finalCallback : callable

Callback function to be called to finalize the aggregate operation and return the value. Definition: fini(mixed $content, int $rowNumber): mixed

$argCount : int = -1

Number of arguments this aggregate function takes, -1 for any amount.

Tags
see
https://www.php.net/manual/en/sqlite3.createaggregate.php
Return values
bool

true if the aggregate function was created successfully, false if not.

createCollation()

Registers a PHP function for use as an SQL collating function.

public createCollation(string $name, callable $callback) : bool
Parameters
$name : string

Name of the SQL collating function.

$callback : callable

Callback function that returns -1, 0 or 1 to indicate sort order. Definition: collation(mixed $value1, mixed $value2): int

Tags
see
https://www.php.net/manual/en/sqlite3.createcollation.php
Return values
bool

true if the collating function was registered, false if not.

createFunction()

Register a PHP function for use as an SQL scalar function.

public createFunction(string $name, callable $callback[, int $argCount = -1 ][, int $flags = 0 ]) : bool
Parameters
$name : string

Name of the SQL function.

$callback : callable

Callback function to register. Definition: callback(mixed $value, mixed ...$values): mixed

$argCount : int = -1

Number of arguments this aggregate function takes, -1 for any amount.

$flags : int = 0

A bitset of flags.

Tags
see
https://www.php.net/manual/en/sqlite3.createfunction.php
Return values
bool

execute()

Executes a statement and returns how many rows are affected.

public execute(string $query) : int|string

Does not request results back from the database and thus should have better performance if the consumer doesn't care about them.

Parameters
$query : string

SQL query to execute.

Return values
int|string

Number of rows affected by the query.

executeThrow()

Tries to execute a query but throws an exception if it fails.

public executeThrow(string $query) : void
Parameters
$query : string

Command to execute.

Tags
throws
RuntimeException

If the command failed to execute.

getAffectedRows()

Gets the number of rows affected by the last operation.

public getAffectedRows() : int|string
Return values
int|string

Number of rows affected by the last operation.

getBlobStream()

Opens a BLOB field as a resource.

public getBlobStream(string $table, string $column, int $rowId) : resource
Parameters
$table : string

Name of the source table.

$column : string

Name of the source column.

$rowId : int

ID of the source row.

Tags
throws
RuntimeException

If opening the BLOB failed.

Return values
resource

BLOB field as a file resource.

getLastErrorCode()

Gets the last error code.

public getLastErrorCode() : int
Return values
int

Last error code.

getLastErrorString()

Gets the last error string.

public getLastErrorString() : string
Return values
string

Last error string.

getLastInsertId()

Returns the ID of the last inserted row.

public getLastInsertId() : int|string
Return values
int|string

Last inserted ID.

prepare()

Prepares a statement for execution and returns a database statement instance.

public prepare(string $query) : DbStatement

The statement should use question mark (?) parameters.

Parameters
$query : string

SQL query to prepare.

Return values
DbStatement

An instance of an implementation of DbStatement.

query()

Executes a statement and returns a database result instance.

public query(string $query) : DbResult
Parameters
$query : string

SQL query to execute.

Return values
DbResult

An instance of an implementation of DbResult

setAuthorizer()

Sets a callback to be used as an authorizer to limit what statements can do.

public setAuthorizer(callable|null $callback) : bool
Parameters
$callback : callable|null

An authorizer callback or null to remove the previous authorizer. Definition: authorizer(int $actionCode, mixed $param2, mixed $param3, string $database, mixed $trigger): int $param2 and $param3 differ based on $actionCode. Must return one of the OK, DENY or IGNORE constants.

Return values
bool

true if the action was successful, false if not.

throwLastError()

Throws the last error as a RuntimeException.

public throwLastError() : never
Tags
throws
RuntimeException

Based on the last error code and string.

Return values
never

        
On this page

Search results