Compare commits

..

2 Commits

Author SHA1 Message Date
Arsen Mirzaev Tatyano-Muradovich 453cac0b77 resolved #1 2025-02-13 08:52:44 +03:00
Arsen Mirzaev Tatyano-Muradovich 3e095e14f7 return values fix 2024-10-12 19:21:25 +03:00
2 changed files with 10 additions and 7 deletions

View File

@ -12,7 +12,8 @@ use mirzaev\arangodb\connection,
// Library for ArangoDB // Library for ArangoDB
use ArangoDBClient\Statement as _statement, use ArangoDBClient\Statement as _statement,
ArangoDBClient\Document as _document, ArangoDBClient\Document as _document,
ArangoDBClient\CollectionHandler as _collection_handler; ArangoDBClient\CollectionHandler as _collection_handler,
ArangoDBClient\Cursor as cursor;
// Built-in libraries // Built-in libraries
use exception; use exception;
@ -85,11 +86,12 @@ class collection
* *
* @param string $query Query (AQL) * @param string $query Query (AQL)
* @param array $parameters Binded parameters for placeholders [placholder => parameter] * @param array $parameters Binded parameters for placeholders [placholder => parameter]
* @param bool $flat Not implement record?
* @param array &$errors Registry of errors * @param array &$errors Registry of errors
* *
* @return _document|array|string|int|null Instance of the document * @return _document|array|string|int|null Instance of the document
*/ */
public static function execute(string $query, array $parameters = [], array &$errors = []): _document|string|array|int|null public static function execute(string $query, array $parameters = [], bool $flat = false, array &$errors = []): _document|string|array|int|null
{ {
try { try {
// Statement instance initialization // Statement instance initialization
@ -97,8 +99,9 @@ class collection
connection::$session, connection::$session,
[ [
'query' => $query, 'query' => $query,
"batchSize" => 1000, 'batchSize' => 1000,
"sanitize" => true 'sanitize' => true,
cursor::ENTRY_FLAT => $flat
] ]
); );
@ -179,10 +182,10 @@ class collection
// Count and exit (success) // Count and exit (success)
return static::execute( return static::execute(
<<<'AQL' <<<'AQL'
RETURN LENGTH(@collection) RETURN LENGTH(@@collection)
AQL, AQL,
[ [
'collection' => $collection '@collection' => $collection
] ]
); );
} catch (exception $e) { } catch (exception $e) {

View File

@ -51,7 +51,7 @@ class document
bool $check = false, bool $check = false,
?terminal $terminal = null, ?terminal $terminal = null,
array &$errors = [] array &$errors = []
): ?string { ): string|null|false {
try { try {
// Инициализация коллекции // Инициализация коллекции
collection::initialize($collection, isset($data['_from'], $data['_to']) ? type::edge : type::document); collection::initialize($collection, isset($data['_from'], $data['_to']) ? type::edge : type::document);