You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
5 months ago
|
<?php
|
||
|
|
||
|
// https://github.com/owoalex/deegraph/blob/main/docs/query-select.md#examples
|
||
|
|
||
|
global $db;
|
||
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||
|
require_once __DIR__ . '/../examples/connection.php';
|
||
|
|
||
|
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator;
|
||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\SelectQueryBuilder;
|
||
|
use Darksparrow\DeegraphInteractions\QueryInstance\SelectQuery;
|
||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
|
||
|
|
||
|
function Example0(): SelectQuery
|
||
|
{
|
||
|
$queryBuilder = QueryBuilder::Select()
|
||
|
->RelativePath(relativePath: ".")
|
||
|
->Where(target: "name", operator: DeegraphEqualityOperator::IS, value: "Peter Evans")
|
||
|
->From("**");
|
||
|
|
||
|
return $queryBuilder->Build();
|
||
|
}
|
||
|
function Example1(): SelectQuery
|
||
|
{
|
||
|
$queryBuilder = QueryBuilder::Select()
|
||
|
->RelativePaths(relativePaths: [
|
||
|
"email_address",
|
||
|
"name",
|
||
|
])
|
||
|
->Where(target: "display_name", operator: DeegraphEqualityOperator::IS, value: "Peter")
|
||
|
->From("**")
|
||
|
->InstanceOf(schema: "https://schemas.auxiliumsoftware.co.uk/v1/user.json");
|
||
|
|
||
|
return $queryBuilder->Build();
|
||
|
}
|
||
|
|
||
|
|
||
|
$result = Example0()->RunQuery($db);
|
||
|
foreach($result->FlattenRows() as $row)
|
||
|
{
|
||
|
echo "$row\n";
|
||
|
}
|