1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace LaravelFreelancerNL\FluentAQL\AQL; |
6
|
|
|
|
7
|
|
|
use LaravelFreelancerNL\FluentAQL\Clauses\RawClause; |
8
|
|
|
use LaravelFreelancerNL\FluentAQL\Exceptions\BindException; |
9
|
|
|
use LaravelFreelancerNL\FluentAQL\Expressions\BindExpression; |
10
|
|
|
use LaravelFreelancerNL\FluentAQL\Expressions\Expression; |
11
|
|
|
use LaravelFreelancerNL\FluentAQL\Expressions\LiteralExpression; |
12
|
|
|
use LaravelFreelancerNL\FluentAQL\QueryBuilder; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Trait hasFunctions. |
16
|
|
|
* |
17
|
|
|
* AQL Function API calls. |
18
|
|
|
*/ |
19
|
|
|
trait HasSupportCommands |
20
|
|
|
{ |
21
|
|
|
abstract public function addCommand($command); |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param object|array<mixed>|string|int|float|bool|null $data |
25
|
|
|
*/ |
26
|
|
|
abstract public function bind( |
27
|
|
|
object|array|string|int|float|bool|null $data, |
28
|
|
|
string $to = null |
29
|
|
|
): BindExpression; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param array<object|array<mixed>|string|int|float|bool|null> $binds |
33
|
|
|
* @param array<string, string|Expression|QueryBuilder> $collections |
34
|
|
|
* @throws BindException |
35
|
|
|
*/ |
36
|
3 |
|
public function raw( |
37
|
|
|
string $aql, |
38
|
|
|
array $binds = [], |
39
|
|
|
array $collections = [] |
40
|
|
|
): self { |
41
|
3 |
|
$this->bindArrayValues($binds); |
|
|
|
|
42
|
|
|
|
43
|
3 |
|
foreach ($collections as $mode => $modeCollections) { |
44
|
1 |
|
$this->registerCollections($modeCollections, $mode); |
45
|
|
|
} |
46
|
|
|
|
47
|
3 |
|
$this->addCommand(new RawClause($aql)); |
48
|
|
|
|
49
|
3 |
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
abstract public function registerCollections($collections, $mode = 'write'); |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param array<array-key, array<array-key, mixed>|null|object|scalar> $binds |
|
|
|
|
56
|
|
|
* @param array<string, string|Expression|QueryBuilder> $collections |
57
|
|
|
* @throws BindException |
58
|
|
|
*/ |
59
|
3 |
|
public function rawExpression( |
60
|
|
|
string $aql, |
61
|
|
|
array $binds = [], |
62
|
|
|
array $collections = [] |
63
|
|
|
): LiteralExpression { |
64
|
3 |
|
$this->bindArrayValues($binds); |
65
|
|
|
|
66
|
3 |
|
foreach ($collections as $mode => $modeCollections) { |
67
|
1 |
|
$this->registerCollections($modeCollections, $mode); |
68
|
|
|
} |
69
|
|
|
|
70
|
3 |
|
return new LiteralExpression($aql); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|