forked from nahid/jsonq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax.php
More file actions
29 lines (24 loc) · 644 Bytes
/
max.php
File metadata and controls
29 lines (24 loc) · 644 Bytes
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
<?php
/**
* Example: max($column = null)
* ================================
*
* max() method return maximum value of resulting data
*/
require_once '../vendor/autoload.php';
use Nahid\JsonQ\Jsonq;
$q = new Jsonq('data.json');
try {
$res = $q
->from('products')
->where('cat', '=', 2)
->max('price');
//from plain array collection
$res1 = $q->collect([2, 10, 1, 5, 7])
->max();
dump($res, $res1);
} catch (\Nahid\JsonQ\Exceptions\ConditionNotAllowedException $e) {
echo $e->getMessage();
} catch (\Nahid\JsonQ\Exceptions\NullValueException $e) {
echo $e->getMessage();
}