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); echo 'Delete record result: ' . var_export($result, true) . PHP_EOL . PHP_EOL; echo 'Retry load record...' . PHP_EOL; $recordLoaded2 = $db->recordLoad($recordLoaded->recordID);
$links = array(); foreach ($keys as $key) { $links[] = $result[$key]; } array_walk($links, $callback); try { $db->recordUpdate('2:' . $rand_record, 'Name:"Bill",Id:' . $i . ', map:[' . implode(',', $links) . ']'); $linked_records[] = $rand_record; } catch (OrientDBException $e) { echo $e->getMessage() . PHP_EOL; } } echo 'Done update ' . $records . PHP_EOL; echo microtime(true) - $time_c . PHP_EOL; $time_c = microtime(true); $record = $db->recordLoad('2:' . $result[count($result) - 1], '*:-1'); echo 'Done get last' . PHP_EOL; echo microtime(true) - $time_c . PHP_EOL; $time_c = microtime(true); $db->setDebug(true); try { $record = $db->recordLoad('2:' . $linked_records[count($linked_records) - 1], '*:10'); } catch (OrientDBException $e) { echo $e->getMessage() . PHP_EOL; } $db->setDebug(false); echo 'Done get linked' . PHP_EOL; echo microtime(true) - $time_c . PHP_EOL; var_dump($record->content); $time_c = microtime(true); for ($i = 0; $i < count($result); $i++) {