LibSQLTransaction Class
LibSQL PHP Extension class LibSQLTransaction
The LibSQLTransaction
class represents a database transaction in the LibSQL PHP Extension. It provides methods to manage database transactions, execute SQL statements within transactions, and retrieve transaction details.
Class Synopsis
Table of Contents
__construct(string $conn_id, string $trx_mode)
: Creates a newLibSQLTransaction
instance.changes(): int
: Retrieves the number of rows changed by the last SQL statement executed within the transaction.isAutocommit(): bool
: Checks if the transaction is set to autocommit.exec(string $stmt, array $parameters = []): int
: Executes an SQL statement within the transaction and returns the number of affected rows.query(string $stmt, array $parameters = []): array
: Executes a query within the transaction and returns the result set.commit(): void
: Commits the transaction.rollback(): void
: Rolls back the transaction.
Description
-
__construct(string trx_mode): Construct by
LibSQL::transaction()
. -
changes(): int: Returns the number of rows changed by the last SQL statement executed within the transaction.
-
isAutocommit(): bool: Checks if the transaction is set to autocommit.
-
exec(string parameters = []): int: Executes an SQL statement within the transaction with optional parameters and returns the number of affected rows.
-
query(string parameters = []): array: Executes a query within the transaction with optional parameters and returns the result set as an array.
-
commit(): void: Commits the transaction, making all changes permanent.
-
rollback(): void: Rolls back the transaction, undoing all changes made within the transaction.
Example
Notes
Ensure proper error handling and transaction management when using the LibSQLTransaction
class to handle potential errors and ensure data integrity.
Was this page helpful?