PHP code example of gumphp / laravel-duckdb

1. Go to this page and download the library: Download gumphp/laravel-duckdb 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/ */

    

gumphp / laravel-duckdb example snippets


'duckdb' => [
    'driver' => 'duckdb',
    'database' => env('DUCKDB_DATABASE', ':memory:'),
    'prefix' => '',
    'config' => [
        'threads' => env('DUCKDB_THREADS', 4),
    ],
],

// 使用查询构建器
$users = DB::connection('duckdb')->table('users')->get();

// 插入数据
DB::connection('duckdb')->table('users')->insert([
    ['name' => 'John Doe', 'email' => '[email protected]'],
    ['name' => 'Jane Smith', 'email' => '[email protected]']
]);

// 更新数据
DB::connection('duckdb')->table('users')
    ->where('name', 'John Doe')
    ->update(['email' => '[email protected]']);

// 删除数据
DB::connection('duckdb')->table('users')
    ->where('name', 'Jane Smith')
    ->delete();

// 创建表
Schema::connection('duckdb')->create('users', function ($table) {
    $table->string('name');
    $table->string('email');
});

// 删除表
Schema::connection('duckdb')->dropIfExists('users');