Cerys Lewis
5 months ago
12 changed files with 153 additions and 34 deletions
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
// https://github.com/owoalex/deegraph/blob/main/docs/query-delete.md#examples |
|||
|
|||
global $db; |
|||
require_once __DIR__ . '/../vendor/autoload.php'; |
|||
require_once __DIR__ . '/../examples/connection.php'; |
|||
|
|||
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder; |
|||
use Darksparrow\DeegraphInteractions\QueryInstance\DeleteQuery; |
|||
|
|||
function Example0(): DeleteQuery |
|||
{ |
|||
$queryBuilder = QueryBuilder::Delete() |
|||
->RelativePath(relativePath: ""); |
|||
|
|||
return $queryBuilder->Build(); |
|||
} |
|||
|
|||
$result = Example0()->RunQuery($db); |
|||
var_dump($result); |
@ -0,0 +1,41 @@ |
|||
<?php |
|||
|
|||
require_once __DIR__ . '/../vendor/autoload.php'; |
|||
|
|||
use Darksparrow\DeegraphInteractions\Core\DeegraphServer; |
|||
use Darksparrow\DeegraphInteractions\DataStructures\DataURL; |
|||
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder; |
|||
|
|||
$db = new DeegraphServer( |
|||
token: "UFVUX1lPVVJfVE9LRU5fSEVSRQ==", |
|||
actor: "db36576b-cc5c-573a-8ae2-00258884d8c6", |
|||
allowSelfSignedCerts: true, |
|||
); |
|||
/* |
|||
$insertQuery = QueryBuilder::Put() |
|||
->Schema(schema: "https://schemas.auxiliumsoftware.co.uk/v1/collection.json") |
|||
->At(relativePath: "{970334ed-1f4f-465a-94d7-923a99698786}/todo"); |
|||
$insertQuery = QueryBuilder::Put() |
|||
->URI(uri: DataURL::BuildBase64(unencodedString: "nya~")) |
|||
->At(relativePath: "{970334ed-1f4f-465a-94d7-923a99698786}/example"); |
|||
$insertQuery = QueryBuilder::Insert() |
|||
->RelativePath(relativePath: "{970334ed-1f4f-465a-94d7-923a99698786}/example"); |
|||
echo $insertQuery; |
|||
echo "\n"; |
|||
$result = $db->RunQuery($insertQuery); |
|||
var_dump($result); |
|||
*/ |
|||
|
|||
$selectQueryBuilder = QueryBuilder::Select() |
|||
->RelativePath(relativePath: ".") |
|||
->From(target: "**"); |
|||
|
|||
$selectQuery = $selectQueryBuilder->Build(); |
|||
|
|||
$result = $selectQuery->RunQuery($db); |
|||
|
|||
foreach($result->FlattenRows() as $row) |
|||
{ |
|||
echo "$row\n"; |
|||
} |
|||
|
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
namespace Darksparrow\DeegraphInteractions\DataStructures; |
|||
|
|||
class DataURL |
|||
{ |
|||
private string $Data; |
|||
private string $MIMEType; |
|||
|
|||
public function __construct(string $mimeType, string $data) |
|||
{ |
|||
$this->Data = $data; |
|||
$this->MIMEType = $mimeType; |
|||
} |
|||
|
|||
public static function FromDataURL(string $dataURL): DataURL |
|||
{ |
|||
|
|||
} |
|||
|
|||
public static function BuildBase64(string $unencodedString): DataURL |
|||
{ |
|||
return new DataURL(mimeType: "text/plain", data: "base64," . base64_encode(string: $unencodedString)); |
|||
} |
|||
|
|||
public function __toString(): string |
|||
{ |
|||
$builder = "data:"; |
|||
$builder .= $this->MIMEType; |
|||
$builder .= ","; |
|||
$builder .= urlencode(string: $this->Data); |
|||
|
|||
return $builder; |
|||
} |
|||
} |
Loading…
Reference in new issue