Ejemplo n.º 1
0
<?php

// draw the tree by index
// default index: -1 show all tree
//
$file = $_SERVER['argv'][1] ? $_SERVER['argv'][1] : 'test.hdb';
$index = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : 1;
if (strrchr($file, '.') == '.xdb') {
    require "xdb.class.php";
    $db = new XTreeDB();
} else {
    require "hdb.class.php";
    $db = new HashTreeDB();
}
$db->open($file, "w");
if ($index >= 0) {
    echo "Before optimize tree data:\n";
    echo "-------------------------------------------------\n";
    $db->draw($index);
}
// optimize table
$db->optimize($index);
if ($index >= 0) {
    echo "After optimize tree data:\n";
    echo "-------------------------------------------------\n";
    $db->draw($index);
}
$db->close();
Ejemplo n.º 2
0
<?php

// draw the tree by index
// default index: -1 show all tree
//
$file = $_SERVER['argv'][1] ? $_SERVER['argv'][1] : 'test.hdb';
if (strrchr($file, '.') == '.xdb') {
    require "xdb.class.php";
    $db = new XTreeDB();
} else {
    require "hdb.class.php";
    $db = new HashTreeDB();
}
$db->open($file, "r");
$db->draw(isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : -1);
$db->close();
Ejemplo n.º 3
0
set_time_limit(0);
ini_set('memory_limit', '128M');
if (!isset($_SERVER['argv'][2])) {
    echo "Usage: {$_SERVER['argv'][0]} <input file> <output file>\n";
    echo "       {$_SERVER['argv'][0]} dict.txt dict.hdb\n";
    echo "       {$_SERVER['argv'][0]} dict.txt dict.xdb\n";
    echo "       {$_SERVER['argv'][0]} dict.txt dict.cdb\n\n";
    exit(0);
}
// get the paramters
$input = $_SERVER['argv'][1];
$output = $_SERVER['argv'][2];
// create the dbm file
if (strrchr($output, '.') == '.hdb') {
    require 'hdb.class.php';
    $db = new HashTreeDB(0, 0x3ffd);
    $ok = $db->Open($output, 'w');
}
if (strrchr($output, '.') == '.xdb') {
    require 'xdb.class.php';
    $db = new XTreeDB(0, 0x3ffd);
    $ok = $db->Open($output, 'w');
} else {
    require 'dba.class.php';
    $db = new DbaHandler();
    $ok = $db->Open($output, 'n');
}
if (!$ok) {
    echo "ERROR: cann't setup the database({$output}).\n";
    exit(0);
}