|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
|
|
4
|
|
|
namespace TBolier\RethinkQL\Query; |
|
5
|
|
|
|
|
6
|
|
|
use TBolier\RethinkQL\Query\Operation\DbCreate; |
|
7
|
|
|
use TBolier\RethinkQL\Query\Operation\DbDrop; |
|
8
|
|
|
use TBolier\RethinkQL\Query\Operation\DbList; |
|
9
|
|
|
use TBolier\RethinkQL\Query\Operation\TableCreate; |
|
10
|
|
|
use TBolier\RethinkQL\Query\Operation\TableDrop; |
|
11
|
|
|
use TBolier\RethinkQL\Query\Operation\TableList; |
|
12
|
|
|
use TBolier\RethinkQL\RethinkInterface; |
|
13
|
|
|
|
|
14
|
|
|
class Database extends AbstractQuery |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var QueryInterface |
|
18
|
|
|
*/ |
|
19
|
|
|
private $query; |
|
20
|
|
|
|
|
21
|
|
|
public function __construct(RethinkInterface $rethink) |
|
22
|
|
|
{ |
|
23
|
|
|
parent::__construct($rethink); |
|
24
|
|
|
|
|
25
|
|
|
$this->dbList(); |
|
26
|
14 |
|
} |
|
27
|
|
|
|
|
28
|
14 |
|
public function dbCreate(string $name): Database |
|
29
|
|
|
{ |
|
30
|
14 |
|
$this->query = new DbCreate($this->rethink, $name); |
|
31
|
14 |
|
|
|
32
|
|
|
return $this; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function dbDrop(string $name): Database |
|
36
|
13 |
|
{ |
|
37
|
|
|
$this->query = new DbDrop($this->rethink, $name); |
|
38
|
13 |
|
|
|
39
|
|
|
return $this; |
|
40
|
13 |
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function dbList(): Database |
|
43
|
|
|
{ |
|
44
|
|
|
$this->query = new DbList($this->rethink); |
|
45
|
|
|
|
|
46
|
14 |
|
return $this; |
|
47
|
|
|
} |
|
48
|
14 |
|
|
|
49
|
|
|
public function tableList(): Database |
|
50
|
14 |
|
{ |
|
51
|
|
|
$this->query = new TableList($this->rethink); |
|
52
|
|
|
|
|
53
|
|
|
return $this; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
14 |
|
public function tableCreate(string $name): Database |
|
57
|
|
|
{ |
|
58
|
14 |
|
$this->query = new TableCreate($this->rethink, $name); |
|
59
|
|
|
|
|
60
|
14 |
|
return $this; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function tableDrop(string $name): Database |
|
64
|
|
|
{ |
|
65
|
|
|
$this->query = new TableDrop($this->rethink, $name); |
|
66
|
12 |
|
|
|
67
|
|
|
return $this; |
|
68
|
12 |
|
} |
|
69
|
|
|
|
|
70
|
12 |
|
public function toArray(): array |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->query->toArray(); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|