1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* The MIT License |
5
|
|
|
* |
6
|
|
|
* Copyright 2017 David Schoenbauer <[email protected]>. |
7
|
|
|
* |
8
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
9
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
10
|
|
|
* in the Software without restriction, including without limitation the rights |
11
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
13
|
|
|
* furnished to do so, subject to the following conditions: |
14
|
|
|
* |
15
|
|
|
* The above copyright notice and this permission notice shall be included in |
16
|
|
|
* all copies or substantial portions of the Software. |
17
|
|
|
* |
18
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
24
|
|
|
* THE SOFTWARE. |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace DSchoenbauer\Sql; |
28
|
|
|
|
29
|
|
|
use DSchoenbauer\Sql\Command\Create; |
30
|
|
|
use DSchoenbauer\Sql\Command\Delete; |
31
|
|
|
use DSchoenbauer\Sql\Command\Select; |
32
|
|
|
use DSchoenbauer\Sql\Command\Update; |
33
|
|
|
use DSchoenbauer\Sql\Where\WhereStatementInterface; |
34
|
|
|
use PDO; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Description of Sql |
38
|
|
|
* |
39
|
|
|
* @author David Schoenbauer <[email protected]> |
40
|
|
|
*/ |
41
|
|
|
class Query { |
42
|
|
|
|
43
|
|
|
public static function with(){ |
44
|
|
|
return new static(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function create($table, array $data) { |
48
|
|
|
return new Create($table, $data); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function select($table, $fields = [], WhereStatementInterface $where = null, $fetchStyle = PDO::FETCH_ASSOC, $fetchFlat = false, $defaultValue = []) { |
52
|
|
|
return new Select($table, $fields, $where, $fetchStyle, $fetchFlat, $defaultValue); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param string $table |
57
|
|
|
* @param array $data |
58
|
|
|
* @param WhereStatementInterface $where |
59
|
|
|
* @return Update |
60
|
|
|
*/ |
61
|
|
|
public function update($table, array $data, WhereStatementInterface $where = null) { |
62
|
|
|
return new Update($table, $data, $where); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param type $table |
67
|
|
|
* @param WhereStatementInterface $where |
68
|
|
|
* @return Delete |
69
|
|
|
*/ |
70
|
|
|
public function delete($table, WhereStatementInterface $where = null){ |
71
|
|
|
return new Delete($table, $where); |
72
|
|
|
} |
73
|
|
|
} |
|
|
|
|
74
|
|
|
|
This check marks files that end in a newline character, i.e. an empy line.