You can work with embedded replicas by passing a path, url and authToken.
Embedded replicas can sync from the remote URL and delegate writes to the
remote primary database:
$db = new Database( path: 'test.db', url: getenv('TURSO_URL'), authToken: getenv('TURSO_AUTH_TOKEN'),);
The readYourWrites parameter configures the database connection to ensure
that writes are immediately visible to subsequent read operations initiated by
the same connection. This is enabled by default, and is particularly
important in distributed systems to ensure consistency from the perspective of
the writing process.You can disable this behavior by passing false:
A batch consists of multiple SQL statements executed sequentially within an
implicit transaction. The backend handles the transaction: success commits all
changes, while any failure results in a full rollback with no modifications.
$conn->execute_batch(" CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY, name TEXT NOT NULL ); INSERT INTO users (name) VALUES ('Alice'); INSERT INTO users (name) VALUES ('Bob');");
Interactive transactions in SQLite ensure the consistency of a series of read
and write operations within a transaction’s scope. These transactions give you
control over when to commit or roll back changes, isolating them from other
client activity.
$tx = conn->transaction();$tx->execute("INSERT INTO users (name) VALUES (?1)", ["Iku"]);$tx->execute("INSERT INTO users (name) VALUES (?1)", ["Iku 2"]);tx->commit(); // or, $tx->rollback()