-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathexport.php
37 lines (30 loc) · 982 Bytes
/
export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace ArangoDBClient;
require __DIR__ . '/init.php';
try {
$connection = new Connection($connectionOptions);
// creates an export object for collection 'users'
$export = new Export($connection, 'users', [
'batchSize' => 5000,
'_flat' => true,
'flush' => true,
'restrict' => [
'type' => 'include',
'fields' => ['_key', '_rev']
]
]
);
// execute the export. this will return a special, forward-only cursor
$cursor = $export->execute();
// now we can fetch the documents from the collection in blocks
while ($docs = $cursor->getNextBatch()) {
// do something with $docs
print sprintf('retrieved %d documents', count($docs)) . PHP_EOL;
}
} catch (ConnectException $e) {
print $e . PHP_EOL;
} catch (ServerException $e) {
print $e . PHP_EOL;
} catch (ClientException $e) {
print $e . PHP_EOL;
}