1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kalanis\kw_mapper\Storage\Database\Dialects; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\kw_mapper\MapperException; |
7
|
|
|
use kalanis\kw_mapper\Storage\Shared\QueryBuilder; |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class ADialect |
12
|
|
|
* @package kalanis\kw_mapper\Storage\Database\Dialects |
13
|
|
|
* All actions as defined by CRUD - Create, Read, Update, Delete |
14
|
|
|
* |
15
|
|
|
* Hints: |
16
|
|
|
* For testing purposes we just fill prepared data and by that we got query. Implemention details are the problem |
17
|
|
|
* of dialect of each language. And it's simple to test that. Then result go to the real connection. |
18
|
|
|
* |
19
|
|
|
* @todo: |
20
|
|
|
* -> database operations - table create, table drop, table alter, ... |
21
|
|
|
* |
22
|
|
|
* Escaping of params has been determined on following links: |
23
|
|
|
* @link http://sqlfiddle.com/ |
24
|
|
|
* @link https://sqliteonline.com |
25
|
|
|
*/ |
26
|
|
|
abstract class ADialect |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Create data by properties |
30
|
|
|
* @param QueryBuilder $builder |
31
|
|
|
* @throws MapperException |
32
|
|
|
* @return string|object |
33
|
|
|
*/ |
34
|
|
|
abstract public function insert(QueryBuilder $builder); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Read data described by conditions |
38
|
|
|
* @param QueryBuilder $builder |
39
|
|
|
* @throws MapperException |
40
|
|
|
* @return string|object |
41
|
|
|
*/ |
42
|
|
|
abstract public function select(QueryBuilder $builder); |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Update data properties described by conditions |
46
|
|
|
* @param QueryBuilder $builder |
47
|
|
|
* @throws MapperException |
48
|
|
|
* @return string|object |
49
|
|
|
*/ |
50
|
|
|
abstract public function update(QueryBuilder $builder); |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Delete data by conditions |
54
|
|
|
* @param QueryBuilder $builder |
55
|
|
|
* @throws MapperException |
56
|
|
|
* @return string|object |
57
|
|
|
*/ |
58
|
|
|
abstract public function delete(QueryBuilder $builder); |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get table structure |
62
|
|
|
* @param QueryBuilder $builder |
63
|
|
|
* @throws MapperException |
64
|
|
|
* @return string|object |
65
|
|
|
*/ |
66
|
|
|
abstract public function describe(QueryBuilder $builder); |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get array of available join operations |
70
|
|
|
* @return string[] |
71
|
|
|
*/ |
72
|
|
|
abstract public function availableJoins(): array; |
73
|
|
|
|
74
|
4 |
|
protected function selectAllColumns(): string |
75
|
|
|
{ |
76
|
4 |
|
return '*'; |
77
|
|
|
} |
78
|
|
|
|
79
|
3 |
|
protected function selectAllProperties(): string |
80
|
|
|
{ |
81
|
3 |
|
return '1=1'; |
82
|
|
|
} |
83
|
|
|
|
84
|
11 |
|
public function singlePropertyEntry(QueryBuilder\Property $column): string |
85
|
|
|
{ |
86
|
11 |
|
return $column->getColumnKey(); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|