Esempio n. 1
0
<?php

// test query
$input = $_SERVER['argv'][1] ? $_SERVER['argv'][1] : 'dict.hdb';
$word = $_SERVER['argv'][2] ? $_SERVER['argv'][2] : '²âÊÔ';
// open the dbm file
if (strrchr($input, '.') == '.hdb') {
    require 'hdb.class.php';
    $db = new HashTreeDB();
} else {
    if (strrchr($input, '.') == '.xdb') {
        require 'xdb.class.php';
        $db = new XTreeDB();
    } else {
        require 'dba.class.php';
        $db = new DbaHandler();
    }
}
if (!($ok = $db->Open($input, 'r'))) {
    echo "ERROR: cann't open the database({$output}).\n";
    exit(0);
}
// compare the value
function get_microtime()
{
    list($usec, $sec) = explode(' ', microtime());
    return (double) $usec + (double) $sec;
}
$start = get_microtime();
$value = $db->get($word);
$tcost = get_microtime() - $start;
Esempio n. 2
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);
}
// check the input file
$fd = fopen($input, "r");
if (!$fd) {
    $db->Close();
    echo "ERROR: cann't read the input file({$input}).\n";
    exit(0);
}
// load the data
$total = 0;