SQLite3
class SQLite3 (View source)
A class that interfaces SQLite 3 databases.
Constants
|
OK
Since: 8.0
|
|
|
DENY
Since: 8.0
|
|
|
IGNORE
Since: 8.0
|
|
|
CREATE_INDEX
Since: 8.0
|
|
|
CREATE_TABLE
Since: 8.0
|
|
|
CREATE_TEMP_INDEX
Since: 8.0
|
|
|
CREATE_TEMP_TABLE
Since: 8.0
|
|
|
CREATE_TEMP_TRIGGER
Since: 8.0
|
|
|
CREATE_TEMP_VIEW
Since: 8.0
|
|
|
CREATE_TRIGGER
Since: 8.0
|
|
|
CREATE_VIEW
Since: 8.0
|
|
|
DELETE
Since: 8.0
|
|
|
DROP_INDEX
Since: 8.0
|
|
|
DROP_TABLE
Since: 8.0
|
|
|
DROP_TEMP_INDEX
Since: 8.0
|
|
|
DROP_TEMP_TABLE
Since: 8.0
|
|
|
DROP_TEMP_TRIGGER
Since: 8.0
|
|
|
DROP_TEMP_VIEW
Since: 8.0
|
|
|
DROP_TRIGGER
Since: 8.0
|
|
|
DROP_VIEW
Since: 8.0
|
|
|
INSERT
Since: 8.0
|
|
|
PRAGMA
Since: 8.0
|
|
|
READ
Since: 8.0
|
|
|
SELECT
Since: 8.0
|
|
|
TRANSACTION
Since: 8.0
|
|
|
UPDATE
Since: 8.0
|
|
|
ATTACH
Since: 8.0
|
|
|
DETACH
Since: 8.0
|
|
|
ALTER_TABLE
Since: 8.0
|
|
|
REINDEX
Since: 8.0
|
|
|
ANALYZE
Since: 8.0
|
|
|
CREATE_VTABLE
Since: 8.0
|
|
|
DROP_VTABLE
Since: 8.0
|
|
|
FUNCTION
Since: 8.0
|
|
|
SAVEPOINT
Since: 8.0
|
|
|
COPY
Since: 8.0
|
|
|
RECURSIVE
Since: 8.0
|
|
Methods
Opens an SQLite database
Closes the database connection
Executes a result-less query against a given database
Returns the SQLite3 library version as a string constant and as a number
Returns the row ID of the most recent INSERT into the database
Returns the numeric result code of the most recent failed SQLite request
Returns English text describing the most recent failed SQLite request
Sets the busy connection handler
Attempts to load an SQLite extension library
Returns the number of database rows that were changed (or inserted or deleted) by the most recent SQL statement
Returns a string that has been properly escaped
Prepares an SQL statement for execution
Executes an SQL query
Executes a query and returns a single result
Registers a PHP function for use as an SQL scalar function
Registers a PHP function for use as an SQL aggregate function
Registers a PHP function for use as an SQL collating function
Opens a stream resource to read a BLOB
Enable throwing exceptions
Instantiates an SQLite3 object and opens an SQLite 3 database
No description
No description
Configures a callback to be used as an authorizer to limit what a statement can do
Details
void
open(string $filename, int $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, string $encryptionKey = '')
Opens an SQLite database
bool
close()
Closes the database connection
bool
exec(string $query)
Executes a result-less query against a given database
static array
version()
Returns the SQLite3 library version as a string constant and as a number
int
lastInsertRowID()
Returns the row ID of the most recent INSERT into the database
int
lastErrorCode()
Returns the numeric result code of the most recent failed SQLite request
string
lastErrorMsg()
Returns English text describing the most recent failed SQLite request
bool
busyTimeout(int $milliseconds)
Sets the busy connection handler
bool
loadExtension(string $name)
Attempts to load an SQLite extension library
int
changes()
Returns the number of database rows that were changed (or inserted or deleted) by the most recent SQL statement
static string
escapeString(string $string)
Returns a string that has been properly escaped
SQLite3Stmt|false
prepare(string $query)
Prepares an SQL statement for execution
SQLite3Result|false
query(string $query)
Executes an SQL query
mixed
querySingle(string $query, bool $entireRow = false)
Executes a query and returns a single result
bool
createFunction(string $name, mixed $callback, int $argCount = -1, int $flags = 0)
Registers a PHP function for use as an SQL scalar function
bool
createAggregate(string $name, mixed $stepCallback, mixed $finalCallback, int $argCount = -1)
Registers a PHP function for use as an SQL aggregate function
bool
createCollation(string $name, callable $callback)
Registers a PHP function for use as an SQL collating function
resource|false
openBlob(string $table, string $column, int $rowid, string $database = 'main', int $flags = SQLITE3_OPEN_READONLY)
Opens a stream resource to read a BLOB
bool
enableExceptions(bool $enable = false)
Enable throwing exceptions
__construct(string $filename, int $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, string $encryptionKey = '')
Instantiates an SQLite3 object and opens an SQLite 3 database
int
lastExtendedErrorCode()
No description
bool
enableExtendedResultCodes(bool $enable = true)
No description
bool
backup(SQLite3 $destination, string $sourceDatabase = 'main', string $destinationDatabase = 'main')
Backup one database to another database
SQLite3::backup copies the contents of one database into another, overwriting the contents of the destination database. It is useful either for creating backups of databases or for copying in-memory databases to or from persistent files.
bool
setAuthorizer(callable|null $callback)
Configures a callback to be used as an authorizer to limit what a statement can do
Sets a callback that will be called by SQLite every time an action is performed (reading, deleting, updating, etc.). This is used when preparing a SQL statement from an untrusted source to ensure that the SQL statements do not try to access data they are not allowed to see, or that they do not try to execute malicious statements that damage the database. For example, an application may allow a user to enter arbitrary SQL queries for evaluation by a database. But the application does not want the user to be able to make arbitrary changes to the database. An authorizer could then be put in place while the user-entered SQL is being prepared that disallows everything except SELECT statements.