PHP code example of keinos / kvsqlite3

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

    

keinos / kvsqlite3 example snippets


 declare(strict_types=1);

   $db = new \KEINOS\KVSQLite3('sample.db');

    // Set a values.
    $db->set('foo', 'bar');
    $db->set('baz', ['qux', 'quux']);

    // Get value.
    echo $db->get('foo'), PHP_EOL;

    // Get a value with default return value.
    echo $db->get('hoge', '"hoge" does not exist.'), PHP_EOL;

    // Delete a value.
    $db->delete('foo');

    // Dump data as SQL queries to a file.
    $db->dump('sample.sql');
} catch (\RuntimeException $e) {
    $msg = 'ERROR:' . $e->getMessage() . PHP_EOL;
    echo $msg;
}


 declare(strict_types=1);

ample.db');

// Set values
$data = [
  'foo'    => 'bar',
  'baz'    => 'qux',
  'quux'   => 'corge',
  'grault' => 'garply',
];
$db->setMultiple($data);

// Get values
$keys = [
  'foo',
  'baz',
];
$result = $db->getMultiple($data);
print_r($result);

// Delete values
$keys = [
  'quux',
  'grault',
];
$db->deleteMultiple($keys);

// Is the key set?
echo $db->has('baz') ? 'baz is set' : 'baz not set', PHP_EOL;

// Clear data
$db->clear();