Example #1
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
// Autoload files using Composer autoload
if (isset($_GET['create'])) {
}
$rel = new \KeysTreeDB\RootNodes(new \KeysTreeDB\FileStorage(__DIR__ . "/zzz.txt"));
$s = [];
$s[] = time();
for ($j = 0; $j < 10; $j++) {
    $sub = new \KeysTreeDB\Nodes();
    for ($i = 0; $i < 10; $i++) {
        $sub->setValue($i, $i);
    }
    $rel->setValue($j, $sub);
    $rel->getValue($j)->setValue(0, 9999);
}
$s[] = time();
for ($j = 0; $j < 10; $j++) {
    $sub = $rel->getValue($j);
    for ($i = 0; $i < 10; $i++) {
        $s[] = '[' . $j . ', ' . $i . '] = ' . $sub->getValue($i);
    }
}
$s[] = time();
echo implode('<br/>', $s);
exit;
Example #2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
// Autoload files using Composer autoload
$keys_file = __DIR__ . "/test1.ndx";
$sqlite_file = __DIR__ . "/test1.sqlite";
if (file_exists($keys_file)) {
    unlink($keys_file);
}
if (file_exists($sqlite_file)) {
    unlink($sqlite_file);
}
$db = new PDO('sqlite:' . $sqlite_file);
$db->exec("CREATE TABLE IF NOT EXISTS users (\n                    id INTEGER PRIMARY KEY,\n                    name TEXT\n    )");
$db->exec("CREATE TABLE IF NOT EXISTS article (\n                    id INTEGER PRIMARY KEY,\n                    name TEXT\n    )");
$rel = new \KeysTreeDB\RootNodes(new \KeysTreeDB\FileStorage($keys_file));
$s = [];
$s[] = time();
$zzz = 1;
for ($j = 1; $j <= 100; $j++) {
    $sub = new \KeysTreeDB\Nodes();
    for ($i = 1; $i <= 1000; $i++) {
        $sub->setValue($i, $zzz++);
    }
    $rel->setValue($j, $sub);
}