PHP Classes
elePHPant
Icontem

File: examples/group-by.php

Recommend this page to a friend!
  Classes of Nahid Bin Azhar  >  PHP JSON Query  >  examples/group-by.php  >  Download  
File: examples/group-by.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP JSON Query
Query JSON data to find and extract information
Author: By
Last change:
Date: 4 months ago
Size: 617 bytes
 

Contents

Class file image Download
<?php
/**
 * Example: groupBy($column = null)
 * ================================
 *
 * groupBy() method helps you to getting grouped data from your
 * desire node/path
 */

require_once '../vendor/autoload.php';

use
Nahid\JsonQ\Jsonq;

$q = new Jsonq('data.json');

try {
   
$res = $q->from('users')->groupBy('location')->get();
   
dump($res);
} catch (\
Nahid\JsonQ\Exceptions\ConditionNotAllowedException $e) {
    echo
$e->getMessage();
} catch (\
Nahid\JsonQ\Exceptions\NullValueException $e) {
    echo
$e->getMessage();
} catch (\
Nahid\JsonQ\Exceptions\InvalidNodeException $e) {
    echo
$e->getMessage();
}