Exemple #1
0
echo 'Creating DB...' . PHP_EOL;
try {
    $result = $db->DBCreate($dbName, OrientDB::DB_TYPE_LOCAL);
    echo 'Opening DB...' . PHP_EOL;
    $clusters = $db->DBOpen($dbName, 'writer', 'writer');
    foreach ($clusters['clusters'] as $cluster) {
        if ($cluster->name === $clusterName) {
            $clusterID = $cluster->id;
        }
    }
    echo 'Create record...' . PHP_EOL;
    $record = new OrientDBRecord();
    $record->data->FirstName = 'Bruce';
    $record->data->LastName = 'Wayne';
    $record->data->appearance = 1938;
    $recordPos = $db->recordCreate($clusterID, $record);
    echo 'Created record position: ' . $recordPos . PHP_EOL . PHP_EOL;
    echo 'Load record...' . PHP_EOL;
    $recordLoaded = $db->recordLoad($clusterID . ':' . $recordPos);
    echo 'Load record result: ' . $recordLoaded . PHP_EOL . PHP_EOL;
    printf('%1$s %2$s first appears in %3$d' . PHP_EOL . PHP_EOL, $recordLoaded->data->FirstName, $recordLoaded->data->LastName, $recordLoaded->data->appearance);
    echo 'Update record...' . PHP_EOL;
    $recordLoaded->data->appearance = 1939;
    $version = $db->recordUpdate($recordLoaded->recordID, $recordLoaded);
    echo 'Updated record version: ' . $version . PHP_EOL . PHP_EOL;
    $recordReLoaded = $db->recordLoad($clusterID . ':' . $recordPos);
    printf('No, %1$s %2$s first appears in %3$d!' . PHP_EOL . PHP_EOL, $recordReLoaded->data->FirstName, $recordReLoaded->data->LastName, $recordReLoaded->data->appearance);
    echo 'Delete record with old version (' . $recordLoaded->version . ') ...' . PHP_EOL;
    $result = $db->recordDelete($recordLoaded->recordID, $recordLoaded->version);
    echo 'Delete record with correct version (' . $version . ') ...' . PHP_EOL;
    $result = $db->recordDelete($recordLoaded->recordID, $version);
Exemple #2
0
 */
require 'OrientDB/OrientDB.php';
$records = 100000;
$time_c = microtime(true);
echo 'Socket' . PHP_EOL;
$db = new OrientDB('localhost', 2424);
echo microtime(true) - $time_c . PHP_EOL;
$time_c = microtime(true);
echo 'OpenDB DB' . PHP_EOL;
$clusters = $db->DBOpen('speedtest', 'admin', 'admin');
echo microtime(true) - $time_c . PHP_EOL;
$time_c = microtime(true);
$result = array();
for ($i = 0; $i < $records; $i++) {
    try {
        $position = $db->recordCreate(2, 'Name:"Bill",Id:' . $i);
        $result[] = $position;
    } catch (OrientDBException $e) {
        echo $e->getMessage() . PHP_EOL;
    }
}
echo 'Done create ' . $records . PHP_EOL;
echo microtime(true) - $time_c . PHP_EOL;
$callback = function (&$item, $key) {
    $item = '#2:' . $item;
};
$time_c = microtime(true);
$linked_records = array();
for ($i = 0; $i < $records / 100; $i++) {
    $rand_record = $result[array_rand($result)];
    $keys = array_rand($result, $records / 100);