12 Commits
0.3.0 ... 1.2.2

9 changed files with 312 additions and 277 deletions

2
.gitignore vendored Normal file → Executable file
View File

@@ -1 +1,3 @@
vendor
composer.lock
!.gitignore

11
LICENSE Normal file
View File

@@ -0,0 +1,11 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# PHP 8.2 Framework for working with ArangoDB
🤟 Very simple and flexible, easy to scale and integrate

16
composer.json Normal file → Executable file
View File

@@ -1,6 +1,7 @@
{
"name": "mirzaev/arangodb",
"description": "Реализация управления хранилищем данных ArangoDB",
"description": "Simple PHP-framework for ArangoDB",
"readme": "README.md",
"keywords": [
"ArangoDB"
],
@@ -15,8 +16,19 @@
"role": "Developer"
}
],
"support": {
"email": "arsen@mirzaev.sexy",
"wiki": "https://git.mirzaev.sexy/mirzaev/arangodb/manual",
"issues": "https://git.mirzaev.sexy/mirzaev/arangodb/issues"
},
"funding": [
{
"type": "funding",
"url": "https://fund.mirzaev.sexy"
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"triagens/arangodb": "~3.8"
},
"require-dev": {

0
composer.lock generated Normal file → Executable file
View File

6
mirzaev/arangodb/system/collection.php Normal file → Executable file
View File

@@ -69,9 +69,9 @@ class collection
* @param _connection $session Сессия соединения с базой данных
* @param string $query AQL-запрос
*
* @return _document|null Инстанция документа
* @return _document|array|string|int|null Инстанция документа
*/
public static function search(_connection $session, string $query): ?_document
public static function search(_connection $session, string $query): _document|string|array|int|null
{
// Поиск журнала
$journal = (new _statement(
@@ -90,7 +90,7 @@ class collection
$buffer[$key] = $value;
}
return $buffer[0] ?? null;
return is_array($buffer) && count($buffer) > 1 ? $buffer : $buffer[0] ?? null;
}
/**

0
mirzaev/arangodb/system/connection.php Normal file → Executable file
View File

29
mirzaev/arangodb/system/document.php Normal file → Executable file
View File

@@ -26,18 +26,17 @@ class document
* @param _connection $session Сессия соединения с базой данных
* @param string $collection Коллекция
* @param ?array $data Данные
* @param ?array $metadata Метаданные
* @param bool $check Проверка на запись в базу данных
* @param ?terminal $terminal Инстанция терминала
*
* @return string|null Идентификатор
*/
public static function write(_connection $session, string $collection, ?array $data = null, ?array $metadata = null, bool $check = true, ?terminal $terminal = null): ?string
public static function write(_connection $session, string $collection, ?array $data = [], bool $check = false, ?terminal $terminal = null): ?string
{
// Инициализация коллекции
collection::init($session, $collection, isset($data['_from'], $data['_to']));
if (isset($metadata['_from'], $metadata['_to'])) {
if (isset($data['_from'], $data['_to'])) {
// Ребро
// Инициализация обработчика рёбер
@@ -47,11 +46,11 @@ class document
$document = new _edge();
// Инициализация вершин
$_from = $metadata['_from'];
$_to = $metadata['_to'];
$_from = $data['_from'];
$_to = $data['_to'];
// Деинициализация из входных данных
unset($metadata['_from'], $metadata['_to']);
unset($data['_from'], $data['_to']);
} else {
// Вершина
@@ -62,7 +61,7 @@ class document
$document = new _document();
}
foreach (['data' => $data, 'metadata' => ($metadata ?? []) + ['created' => time()]] as $key => $value) {
foreach (['created' => time()] + $data as $key => $value) {
// Перебор параметров
// Запись в инстанцию документа
@@ -72,11 +71,18 @@ class document
// Запись на сервер и его ответ в буфер возврата
$id = isset($_from, $_to) ? $documents->saveEdge($collection, $_from, $_to, $document) : $documents->insert($collection, $document);
if ($check && $terminal instanceof terminal && $documents->has($collection, $id)) {
// Документ записан
if ($check && $documents->has($collection, $id)) {
// Найден записанный документ
// Запись в вывод
$terminal::write("В коллекции \"$collection\" создан документ \"$id\"");
if ($terminal instanceof terminal) $terminal::write("В коллекции \"$collection\" создан документ \"$id\"");
} else if ($check) {
// Не найден записанный документ
// Запись в вывод
if ($terminal instanceof terminal) $terminal::write("В коллекции \"$collection\" не удалось найти созданный или создать документ");
return null;
}
// Возврат идентификатора коллекции
@@ -91,7 +97,8 @@ class document
*
* @return bool Статус обработки
*/
public static function update(_connection $session, _document $document): bool {
public static function update(_connection $session, _document $document): bool
{
// Инициализация обработчика вершин
$documents = new _document_handler($session);

0
mirzaev/arangodb/system/terminal.php Normal file → Executable file
View File