1 | <?php |
||
50 | class Builder extends ObjectAbstract implements BuilderInterface |
||
51 | { |
||
52 | use DialectAwareTrait, SettingsAwareTrait, ParameterAwareTrait; |
||
53 | |||
54 | /** |
||
55 | * tables |
||
56 | * |
||
57 | * @var array |
||
58 | * @access protected |
||
59 | */ |
||
60 | protected $tables = []; |
||
61 | |||
62 | /** |
||
63 | * Constructor |
||
64 | * |
||
65 | * ```php |
||
66 | * // builder with default table `users` and Mysql dialect |
||
67 | * $users = new Builder('users', new Mysql()) |
||
68 | * |
||
69 | * // builder with defult tables: `users` and `accounts` AS `a` |
||
70 | * $builder = new Builder(['users', 'accounts' => 'a']) |
||
71 | * |
||
72 | * // change default settings |
||
73 | * $builder = new Builder('users', new Mysql(), ['autoQuote' => false]); |
||
74 | * ``` |
||
75 | * |
||
76 | * @param string|array $table table[s] to build upon |
||
77 | * @param DialectInterface $dialect default dialect is `Mysql` |
||
78 | * @param array $settings builder settings |
||
79 | * @access public |
||
80 | */ |
||
81 | public function __construct( |
||
92 | |||
93 | /** |
||
94 | * Change table[s] |
||
95 | * |
||
96 | * @param $table change to table[s] |
||
97 | * @return $this |
||
98 | * @access public |
||
99 | */ |
||
100 | public function __invoke($table) |
||
104 | |||
105 | /** |
||
106 | * {@inheritDoc} |
||
107 | */ |
||
108 | public function expr()/*# : ExpressionInterface */ |
||
112 | |||
113 | /** |
||
114 | * {@inheritDoc} |
||
115 | */ |
||
116 | public function raw( |
||
125 | |||
126 | /** |
||
127 | * If has existing tables, return a new instance with provided table[s] |
||
128 | * |
||
129 | * {@inheritDoc} |
||
130 | */ |
||
131 | public function table($table, /*# string */ $alias = '') |
||
138 | |||
139 | /** |
||
140 | * Append to existing tables |
||
141 | * |
||
142 | * {@inheritDoc} |
||
143 | */ |
||
144 | public function from($table, /*# string */ $alias = '') |
||
150 | |||
151 | /** |
||
152 | * {@inheritDoc} |
||
153 | */ |
||
154 | public function select()/*# : SelectStatementInterface */ |
||
160 | |||
161 | /** |
||
162 | * {@inheritDoc} |
||
163 | */ |
||
164 | public function insert(array $values = [])/*# : InsertStatementInterface */ |
||
170 | |||
171 | /** |
||
172 | * {@inheritDoc} |
||
173 | */ |
||
174 | public function replace(array $values = [])/*# : InsertStatementInterface */ |
||
180 | |||
181 | /** |
||
182 | * {@inheritDoc} |
||
183 | */ |
||
184 | public function update(array $values = [])/*# : UpdateStatementInterface */ |
||
190 | |||
191 | /** |
||
192 | * {@inheritDoc} |
||
193 | */ |
||
194 | public function delete()/*# : DeleteStatementInterface */ |
||
204 | |||
205 | /** |
||
206 | * {@inheritDoc} |
||
207 | */ |
||
208 | public function union()/*# : UnionStatementInterface */ |
||
220 | |||
221 | /** |
||
222 | * Convert to [$table => alias] or [$table] |
||
223 | * |
||
224 | * @param string|string[] $table |
||
225 | * @param string $alias |
||
226 | * @return array |
||
227 | * @access protected |
||
228 | */ |
||
229 | protected function fixTable( |
||
240 | |||
241 | /** |
||
242 | * Builder default settings |
||
243 | * |
||
244 | * @return array |
||
245 | * @access protected |
||
246 | */ |
||
247 | protected function defaultSettings()/*# : array */ |
||
259 | } |
||
260 |