Index Documentation

SQLiteConnection
in package
implements IDbConnection, IDbTransactions

Represents a client for an SQLite database.

Table of Contents

Interfaces

IDbConnection
Represents a connection to a database service.
IDbTransactions
Indicates supports for transactions in a database connection.

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
Closes the connection and associated resources.
beginTransaction()  : void
Enters a transaction.
close()  : void
commit()  : void
Commits the actions done during a transaction and ends the 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.
getAffectedRows()  : int|string
Gets the number of rows affected by the last operation.
getBlobStream()  : Stream
Opens a BLOB field as a Stream.
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()  : IDbStatement
Prepares a statement for execution and returns a database statement instance.
query()  : IDbResult
Executes a statement and returns a database result instance.
releaseSavePoint()  : void
Releases a save point.
rollback()  : void
Rolls back to the state before a transaction start or to a specified save point.
savePoint()  : void
Creates a save point in the transaction that can be rolled back to.
setAuthorizer()  : bool
Sets a callback to be used as an authorizer to limit what statements can do.
setAutoCommit()  : void
Sets whether changes should be applied immediately or whether commit should always be called first.

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

__destruct()

Closes the connection and associated resources.

public __destruct() : mixed

beginTransaction()

Enters a transaction.

public beginTransaction() : void

commit()

Commits the actions done during a transaction and ends the transaction.

public commit() : void

A new transaction will be started if auto-commit is disabled.

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.

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 Stream.

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

To be used instead of getStream on SQLiteResult.

Parameters
$table : string

Name of the source table.

$column : string

Name of the source column.

$rowId : int

ID of the source row.

Tags
throws
DataException

If opening the BLOB failed.

Return values
Stream

BLOB field as a Stream.

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) : IDbStatement

The statement should use question mark (?) parameters.

Parameters
$query : string

SQL query to prepare.

Return values
IDbStatement

An instance of an implementation of IDbStatement.

query()

Executes a statement and returns a database result instance.

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

SQL query to execute.

Return values
IDbResult

An instance of an implementation of IDbResult

releaseSavePoint()

Releases a save point.

public releaseSavePoint(string $name) : void
Parameters
$name : string

Name of the save point.

rollback()

Rolls back to the state before a transaction start or to a specified save point.

public rollback([string|null $name = null ]) : void
Parameters
$name : string|null = null

Name of the save point, null for the entire transaction.

savePoint()

Creates a save point in the transaction that can be rolled back to.

public savePoint(string $name) : void
Parameters
$name : string

Name for the save point.

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.

setAutoCommit()

Sets whether changes should be applied immediately or whether commit should always be called first.

public setAutoCommit(bool $state) : void
Parameters
$state : bool

true if things should automatically be committed, false if not.


        
On this page

Search results