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