PHP code example of upscale / newrelic-query-builder

1. Go to this page and download the library: Download upscale/newrelic-query-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

upscale / newrelic-query-builder example snippets


use Upscale\Nrql\QueryBuilder;
use Upscale\Nrql\TimePeriod;
use Upscale\Nrql\Moment\TimeAgo;
use Upscale\Nrql\Moment\ExactTime;
use Upscale\Nrql\Moment\Yesterday;

$nrql = new QueryBuilder();
$nrql->select([
        'userAgentName',
    ])
    ->from([
        'PageView',
    ])
    ->where('userAgentOS = "Windows"')
    ->facet('countryCode')
    ->limit(20)
    ->since(new TimeAgo(new TimePeriod(4, TimePeriod::UNIT_DAYS)))
    ->until(new Yesterday())
    ->compareWith(new ExactTime(new \DateTime('2015-01-01 00:00:00')))
    ->timeSeries(new TimePeriod(1, TimePeriod::UNIT_HOURS))
;

echo $nrql;