Cerys Lewis
5 months ago
2 changed files with 68 additions and 6 deletions
@ -1,17 +1,37 @@ |
|||
<?php |
|||
|
|||
// https://github.com/owoalex/deegraph/blob/main/docs/query-grant.md#examples |
|||
|
|||
global $db; |
|||
require_once __DIR__ . '/../vendor/autoload.php'; |
|||
require_once __DIR__ . '/../examples/connection.php'; |
|||
|
|||
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator; |
|||
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphPermissionType; |
|||
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder; |
|||
use Darksparrow\DeegraphInteractions\QueryInstance\GrantQuery; |
|||
|
|||
function Example0(): GrantQuery |
|||
{ |
|||
$queryBuilder = QueryBuilder::Grant() |
|||
->Permissions(permissionTypes: [ |
|||
DeegraphPermissionType::WRITE, |
|||
DeegraphPermissionType::READ, |
|||
]) |
|||
->On(target: "*") |
|||
->IsDelegatable(); |
|||
|
|||
QueryBuilder::Grant() |
|||
return $queryBuilder->Build(); |
|||
} |
|||
function Example1(): GrantQuery |
|||
{ |
|||
$queryBuilder = QueryBuilder::Grant() |
|||
->GrantAll() |
|||
->On(target: "*") |
|||
->Bu($db); |
|||
->IsDelegatable(); |
|||
|
|||
return $queryBuilder->Build(); |
|||
} |
|||
|
|||
|
|||
$result = $db->RunQuery($grantQuery); |
|||
$result = Example0()->RunQuery($db); |
|||
var_dump($result); |
|||
|
@ -0,0 +1,42 @@ |
|||
<?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"; |
|||
} |
Loading…
Reference in new issue