-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.php
42 lines (30 loc) · 911 Bytes
/
demo.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
38
39
40
41
42
<?php
use DocumentStore\Document;
use DocumentStore\DocumentStore;
use DocumentStore\DocumentDatabase;
require __DIR__ . '/vendor/autoload.php';
$path = __DIR__ . '/demo';
if (! is_dir($path)) {
print "Creating directory {$path}\n";
mkdir($path);
}
$store = new DocumentStore($path);
$document = new Document();
$document->title = 'Patterns of Enterprise Application Architecture';
$document->author = 'Martin Fowler';
$document->type = 'hardcover';
$document->isbn = [
'978-0321127426',
'0321127420'
];
$store->set('computing/programming/0321127420', $document);
print PHP_EOL . 'store:list' . PHP_EOL;
print_r($store->list());
$result = $store->get('computing/programming/0321127420');
print PHP_EOL . 'store:get' . PHP_EOL;
print_r($result);
$db = new DocumentDatabase($path);
$db->insert($document);
$id = $document->_id;
print PHP_EOL . 'db' . PHP_EOL;
print_r($db->get($id));