1 | <?php |
||
8 | class Database |
||
9 | { |
||
10 | /** |
||
11 | * @var \TomSchlick\Townhouse\Tenant |
||
12 | */ |
||
13 | protected $tenant; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $config; |
||
19 | |||
20 | /** |
||
21 | * Database constructor. |
||
22 | * |
||
23 | * @param \TomSchlick\Townhouse\Tenant $tenant |
||
24 | * @param array $config |
||
25 | */ |
||
26 | public function __construct(Tenant $tenant, array $config) |
||
31 | |||
32 | /** |
||
33 | * Figure out the database name for the tenant. |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | public function name() : string |
||
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | public function host() : string |
||
49 | |||
50 | /** |
||
51 | * @return string |
||
52 | */ |
||
53 | public function username() : string |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | public function password() : string |
||
65 | |||
66 | /** |
||
67 | * Check if database currently exists in MySQL |
||
68 | * |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function exists() : bool |
||
77 | |||
78 | /** |
||
79 | * Create the tenant database. |
||
80 | * |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function create() |
||
87 | |||
88 | /** |
||
89 | * Drop the tenant database. |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | public function drop() |
||
97 | |||
98 | /** |
||
99 | * Connect this db as the "tenant" db. |
||
100 | */ |
||
101 | public function connect() |
||
106 | |||
107 | /** |
||
108 | * Purge the tenant db connection. |
||
109 | */ |
||
110 | public function purgeConnection() |
||
115 | |||
116 | /** |
||
117 | * Set this DB's connection info to the config. |
||
118 | */ |
||
119 | protected function setDbConfig() |
||
126 | } |
||
127 |