sync() method that can be used when you connect with Remote Replica Connection (Embedded Replica), you can use sync() method with getNativeConnection()->sync().
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use LibSQL Database in Laravel Application
sync() method that can be used when you connect with Remote Replica Connection (Embedded Replica), you can use sync() method with getNativeConnection()->sync().
use Doctrine\DBAL\DriverManager;
require_once __DIR__ . '/vendor/autoload.php';
$params = [
"url" => ":memory:",
'driverClass' => \Darkterminal\LibSQL\DBAL\Driver::class,
];
$db = DriverManager::getConnection($params);
$createTable = "CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
age INTEGER
)";
$db->executeStatement($createTable);
$insertUsers = <<<SQL
INSERT INTO users (name, age) VALUES ('Budi Dalton', 49);
INSERT INTO users (name, age) VALUES ('Sujiwo Tedjo', 50);
SQL;
$db->getNativeConnection()->executeBatch($insertUsers);
$result = $db->executeQuery("SELECT * FROM users")->fetchAllAssociative();
var_dump($result);
$db->close();
Was this page helpful?
