PHP code example of richan-fongdasen / turso-laravel
1. Go to this page and download the library: Download richan-fongdasen/turso-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use App\Models\User;
use Illuminate\Support\Facades\DB;
// Using Query Builder
$users = DB::table('users')->orderBy('name')->get();
// Using Eloquent ORM
$users = User::with('posts')->orderBy('name')->get();
use Illuminate\Support\Facades\DB;
use RichanFongdasen\Turso\Facades\Turso;
if ( DB::hasModifiedRecords() ) {
// Run the sync script immediately
DB::sync();
// Run the sync script in the background
DB::backgroundSync();
}
// Sync on the specific connection
DB::connection('turso')->sync();
DB::connection('turso')->backgroundSync();
// Sync on all of the turso database connections
Turso::sync();
Turso::backgroundSync();
// Enabling query log on default database connection
DB::enableQueryLog();
// Enabling query log on specific connection
DB::connection('turso')->enableQueryLog();
// Perform some queries
DB::table('users')->get();
// Get the query log for default database connection
DB::getQueryLog();
// Get the query log for specific connection
DB::connection('turso')->getQueryLog();