forked from roaatech/php-es-mapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcase3.php
36 lines (31 loc) · 1.07 KB
/
case3.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
<?php
/* * ***
* All the examples suppose there is an ES instance with the following
* index/type/doc architecture:
*
* - tests
* - foo
* - foo1: {name: Fooa, id: 1, age: 33, alive: true}
* - foo2: {name: Foob, id: 2, age: 18, alive: false}
* - bar
* - bar1: {name: Bara, id: 1, age: 33, alive: true}
* - bar2: {name: Barb, id: 2, age: 77, alive: false}
* - bar3: {name: Barc, id: 3, age: 12, alive: false}
*/
require '../vendor/autoload.php';
require_once 'TestsIndexQuery.php';
require_once 'ZeeTypeQuery.php';
require_once 'ZeeModel.php';
function dump_me($id, $model, $extra = null) {
if ($model) {
$class = get_class($model);
echo "{$id} ({$class}): I am {$model->name}. My id is {$model->id}, and I am {$model['age']} years old! $extra<br />";
} else {
echo "{$id} (null): I am not there!<br />";
}
}
//get all of type
foreach (Tests\ZeeTypeQuery::all() as $id => $model) {
/* @var $model Models\Zee */
dump_me($id, $model, "I am " . ($model->alive ? "alive" : "dead"));
}