Repository navigation
Basic Usage
Everything below is exercised by tests/Feature/* and/or the
docker/proof/ integration harness.
use Illuminate\Support\Facades\DB;
// insert
DB::table('users')->insert([
'name' => 'Budi Dalton',
'email' => 'budi.dalton@duck.com',
]);
// read
DB::table('users')->get();
DB::table('users')->where('id', 2)->first();
DB::table('users')->orderBy('id', 'DESC')->limit(2)->get();
// update
DB::table('users')->where('id', 2)->update(['name' => 'Doni Mandala']);
// delete
DB::table('users')->where('id', 2)->delete();Models work the standard way. Relations (HasMany, HasManyThrough,
BelongsToMany), attribute casting (array, bool, int, float, string, date,
datetime, enum), soft deletes, collections — all covered by
tests/Feature/EloquentRelationship/*,
tests/Feature/EloquentAttributeCasting/*,
tests/Feature/EloquentCollectionTest.php,
tests/Feature/EloquentDeleteTest.php, and
tests/Feature/EloquentSoftDeleteTest.php.
php artisan make:migration create_movies_table
php artisan migratedocker/proof/ runs php artisan migrate --force through the driver during
its proof, verifying the full artisan migration path.
DB::beginTransaction();
try {
// …
DB::commit();
} catch (\Throwable $e) {
DB::rollBack();
throw $e;
}Covered by tests/Feature/DatabaseTransactionsTest.php and
tests/Feature/DataTypes/IntegerDataTest.php.
insert() / update() / delete() raise PDOException (Laravel wraps it as
QueryException) on constraint violations instead of returning false. Wrap
your writes in try/catch the same way as with SQLite:
try {
DB::table('users')->insert([...]);
} catch (\Illuminate\Database\QueryException $e) {
report($e);
}libSQL vector types are exposed through the driver.
tests/Feature/DataTypes/VectorDataType.php inserts a vector and runs
nearest-neighbour search against a vector index, using the vectorIndex()
macro (src/Macros/VectorMacro.php). Vector casts are available for Eloquent
(src/Database/Casts/VectorCast.php).
DB::sync() triggers a manual replica sync. Only valid on the embedded
replica connection (remote_replica mode); on other modes it errors. Verified
by the replica phases of docker/proof/.