References
LibSQL Transaction
On this page, you will find more information about the libSQL Transaction and available functions.
The LibSQLTransaction
class represents a database transaction in the LibSQL PHP extension. It allows for executing SQL statements within a transaction context, handling commits, rollbacks, and managing transactional behavior.
Constructor
The libSQL Transaction will construct when you using $db->transaction()
.
Methods
changes
Retrieves the number of rows changed by the last SQL statement.
Returns
- (int) : The number of rows changed.
Example
isAutocommit
Checks if the transaction is set to autocommit.
Returns
- (bool) : if autocommit is enabled return
true
, otherwisefalse
.
Example
execute
Executes an SQL statement within the transaction.
Parameters
string $stmt
: The SQL statement to execute.array $parameters
: The parameters for the statement (optional).
Returns
- (int) : The number of affected rows.
Example
query
Executes a query within the transaction and returns the result set.
Parameters
string $stmt
: The SQL statement to execute.array $parameters
: The parameters for the statement (optional).
Returns
- (LibSQLResult): The result set of the query.
Example
commit
Commits the transaction.
Returns
- (void)
Example
rollback
Rolls back the transaction.
Returns
- (void)