On this page, you will find more information about the libSQL PHP classes and available functions.
The LibSQL
class provides an interface for connecting to and interacting with a LibSQL database. It supports operations such as preparing and executing SQL statements, managing transactions, and retrieving query results.
OPEN_READONLY
: Specifies read-only mode when opening the database connection.OPEN_READWRITE
: Specifies read-write mode when opening the database connection.OPEN_CREATE
: Specifies create mode when opening the database connection.LIBSQL_ASSOC
: Return results as an associative array.LIBSQL_NUM
: Return results as a numerical array.LIBSQL_BOTH
: Return results as both associative and numerical arrays.LIBSQL_ALL
: Return all result sets.LIBSQL_LAZY
: Return a result generator.$mode
: (string)__construct
Creates a new instance of the LibSQL
class to establish a connection to the database.
string|array $config
: Configuration for the database connection.
int|null $flags
(optional): Connection flags (default: 6
- read-write and create mode).string|null $encryption_key
(optional): The encryption key for the database.version
(static)Retrieves the version of the LibSQL library and PHP extension.
changes
Gets the number of rows changed by the last executed SQL statement.
isAutocommit
Checks if autocommit mode is enabled for the connection.
true
if autocommit is enabled, otherwise false
.totalChanges
Gets the total number of rows changed since the database connection was opened.
lastInsertedId
Retrieves the ID of the last inserted row.
execute
Executes a single SQL statement on the database.
string $stmt
: The SQL statement to execute.array $parameters
(optional): Parameters for the SQL statement.executeBatch
Executes a batch of SQL statements.
string $stmt
: The batch of SQL statements to execute.true
if the batch execution was successful, otherwise false
.query
Executes an SQL query and retrieves the result set.
string $stmt
: The SQL query to execute.array $parameters
(optional): Parameters for the query.Read more detail about LibSQLResult Class
transaction
Starts a new database transaction.
string $behavior
(optional): Transaction behavior (default: "DEFERRED"
).Read more detail about LibSQLTransaction Class
prepare
Prepares an SQL statement for execution.
string $sql
: The SQL statement to prepare.Read more detail about LibSQLStatement Class
close
Closes the database connection.
sync
Syncs the database to ensure data integrity.
enableLoadExtension
Enables or disables the loading of extensions.
bool $onoff
: true
to enable extensions, false
to disable.loadExtensions
Loads specified database extensions.
array|string $extension_paths
: Paths to the extensions to load.