PHP code example of lyhiving / filedb

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

    

lyhiving / filedb example snippets



use lyhiving\filedb\filedb;
//指定数据库目录
$db = new filedb(['dir' => __DIR__ . '/db/']);


$item = [
    'name' => 'John-insert',
    'surname' => 'DEMOTE',
    'age' => '20',
    'email' => '[email protected]',
];
$newid = $db->insert('test', $item);

$item = [
    '@id@' =>9,
    'name' => 'Smith',
    'surname' => 'DEMOTE',
    'age' => '20',
    'email' => '[email protected]',
];
$newid = $db->insert('test', $item);
//$newid =9;

$result = $db->select('test'); //or $db->select_all('test');

$row = $db->select('test', 1);

$rows = $db->select('test', array('name' => 'John-insert'));

$rows = $db->delete('test', $newid);

$rows = $db->delete('test');

$result = $db->clone_to_db('test_clone');

$result = $db->save_to_csv($db->select_all('test'));