PHP code example of lombokclarion / persistence

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

    

lombokclarion / persistence example snippets


LombokClarion\Persistence

use LombokClarion\Persistence\QueryBuilder;

$qb = new QueryBuilder($pdo, $grammar);

// Select
$rows = $qb->table('widgets')
    ->where('status', '=', 'active')
    ->orderBy('created_at', 'DESC')
    ->limit(10)
    ->get();

// Insert
$qb->table('widgets')->insert([
    'name' => 'Gadget',
    'status' => 'active',
]);

// Join
$rows = $qb->table('widgets')
    ->join('categories', 'widgets.category_id', '=', 'categories.id')
    ->select('widgets.*', 'categories.name AS category_name')
    ->get();

// Schema
$schema = new SchemaBuilder($pdo, $grammar);
$schema->create('widgets', function ($table) {
    $table->id();
    $table->string('name');
    $table->string('status')->default('draft');
    $table->timestamps();
});