Issues (68)

src/Dialects/Dialect.php (5 issues)

1
<?php
2
/**
3
 * Interface Dialect
4
 *
5
 * @filesource   Dialect.php
6
 * @created      11.01.2018
7
 * @package      chillerlan\Database\Dialects
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2018 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Database\Dialects;
14
15
interface Dialect{
16
17
	/**
18
	 * @param string $str
19
	 *
20
	 * @return string
21
	 */
22
	public function quote(string $str):string;
23
24
	/**
25
	 * @param array       $cols
26
	 * @param array       $from
27
	 * @param string|null $where
28
	 * @param null        $limit
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $limit is correct as it would always require null to be passed?
Loading history...
29
	 * @param null        $offset
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $offset is correct as it would always require null to be passed?
Loading history...
30
	 * @param bool|null   $distinct
31
	 * @param array       $groupby
32
	 * @param array       $orderby
33
	 *
34
	 * @return array
35
	 */
36
	public function select(array $cols, array $from, string $where = null, $limit = null, $offset = null, bool $distinct = null, array $groupby = null, array $orderby = null):array;
37
38
	/**
39
	 * @param array $expressions
40
	 *
41
	 * @return array
42
	 */
43
	public function cols(array $expressions):array;
44
45
	/**
46
	 * @param array $expressions
47
	 *
48
	 * @return array
49
	 */
50
	public function from(array $expressions):array;
51
52
	/**
53
	 * @param array $expressions
54
	 *
55
	 * @return array
56
	 */
57
	public function orderby(array $expressions):array;
58
59
	/**
60
	 * @param array       $from
61
	 * @param string|null $where
62
	 * @param bool|null   $distinct
63
	 * @param array|null  $groupby
64
	 *
65
	 * @return mixed
66
	 */
67
	public function selectCount(array $from, string $where = null, bool $distinct = null, array $groupby = null); // @todo: offset?
68
69
	/**
70
	 * @param string      $table
71
	 * @param array       $fields
72
	 * @param string|null $onConflict
73
	 * @param string|null $conflictTarget
74
	 *
75
	 * @return array
76
	 */
77
	public function insert(string $table, array $fields, string $onConflict = null, string $conflictTarget = null):array;
78
79
	/**
80
	 * @param string $table
81
	 * @param array  $set
82
	 * @param string $where
83
	 *
84
	 * @return array
85
	 */
86
	public function update(string $table, array $set, string $where):array;
87
88
	/**
89
	 * @param string $table
90
	 * @param string $where
91
	 *
92
	 * @return array
93
	 */
94
	public function delete(string $table, string $where):array;
95
96
	/**
97
	 * @param string      $dbname
98
	 * @param bool|null   $ifNotExists
99
	 * @param string|null $collate
100
	 *
101
	 * @return array
102
	 */
103
	public function createDatabase(string $dbname, bool $ifNotExists = null, string $collate = null):array;
104
105
	/**
106
	 * @param string      $table
107
	 * @param array       $cols
108
	 * @param string|null $primaryKey
109
	 * @param bool        $ifNotExists
110
	 * @param bool        $temp
111
	 * @param string|null $dir
112
	 *
113
	 * @return array
114
	 */
115
	public function createTable(string $table, array $cols, string $primaryKey = null, bool $ifNotExists = null, bool $temp = null, string $dir = null):array;
116
117
	/**
118
	 * @param string $dbname
119
	 * @param bool   $ifExists
120
	 *
121
	 * @return mixed
122
	 */
123
	public function dropDatabase(string $dbname, bool $ifExists);
124
125
	/**
126
	 * @param string $table
127
	 * @param bool   $ifExists
128
	 *
129
	 * @return array
130
	 */
131
	public function dropTable(string $table, bool $ifExists):array;
132
133
	/**
134
	 * @param string $table
135
	 *
136
	 * @return array
137
	 */
138
	public function truncate(string $table):array;
139
140
	/**
141
	 * @param string      $name
142
	 * @param string      $type
143
	 * @param null        $length
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $length is correct as it would always require null to be passed?
Loading history...
144
	 * @param string|null $attribute
145
	 * @param string|null $collation
146
	 * @param bool|null   $isNull
147
	 * @param string|null $defaultType
148
	 * @param null        $defaultValue
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $defaultValue is correct as it would always require null to be passed?
Loading history...
149
	 * @param string|null $extra
150
	 *
151
	 * @return string
152
	 */
153
	public function fieldspec(string $name, string $type, $length = null, string $attribute = null, string $collation = null, bool $isNull = null, string $defaultType = null, $defaultValue = null, string $extra = null):string;
154
155
	/**
156
	 * @param string    $name
157
	 * @param array     $values
158
	 * @param null      $defaultValue
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $defaultValue is correct as it would always require null to be passed?
Loading history...
159
	 * @param bool|null $isNull
160
	 *
161
	 * @return string
162
	 */
163
	public function enum(string $name, array $values, $defaultValue = null, bool $isNull = null):string;
164
165
	/**
166
	 * @return array
167
	 */
168
	public function showDatabases():array;
169
170
	/**
171
	 * @param string|null $database
172
	 * @param string|null $pattern
173
	 * @param string|null $where
174
	 *
175
	 * @return array
176
	 */
177
	public function showTables(string $database = null, string $pattern = null, string $where = null):array;
178
179
}
180