1 | <?php |
||
47 | class Builder extends ObjectAbstract implements BuilderInterface |
||
48 | { |
||
49 | use DialectAwareTrait, SettingsAwareTrait, ParameterAwareTrait; |
||
50 | |||
51 | /** |
||
52 | * tables |
||
53 | * |
||
54 | * @var array |
||
55 | * @access protected |
||
56 | */ |
||
57 | protected $tables = []; |
||
58 | |||
59 | /** |
||
60 | * Constructor |
||
61 | * |
||
62 | * ```php |
||
63 | * // builder with default table `users` and Mysql dialect |
||
64 | * $users = new Builder('users', new Mysql()) |
||
65 | * |
||
66 | * // builder with defult tables: `users` and `accounts` AS `a` |
||
67 | * $builder = new Builder(['users', 'accounts' => 'a']) |
||
68 | * |
||
69 | * // change default settings |
||
70 | * $builder = new Builder('users', new Mysql(), ['autoQuote' => false]); |
||
71 | * ``` |
||
72 | * |
||
73 | * @param string|array $table table[s] to build upon |
||
74 | * @param DialectInterface $dialect default dialect is `Mysql` |
||
75 | * @param array $settings builder settings |
||
76 | * @access public |
||
77 | */ |
||
78 | public function __construct( |
||
89 | |||
90 | /** |
||
91 | * Change table[s] |
||
92 | * |
||
93 | * @param $table change to table[s] |
||
94 | * @return $this |
||
95 | * @access public |
||
96 | */ |
||
97 | public function __invoke($table) |
||
101 | |||
102 | /** |
||
103 | * {@inheritDoc} |
||
104 | */ |
||
105 | public function expr()/*# : ExpressionInterface */ |
||
109 | |||
110 | /** |
||
111 | * {@inheritDoc} |
||
112 | */ |
||
113 | public function raw(/*# string */ $string)/*# : OutputInterface */ |
||
123 | |||
124 | /** |
||
125 | * If has existing tables, return a new instance with provided table[s] |
||
126 | * |
||
127 | * {@inheritDoc} |
||
128 | */ |
||
129 | public function table($table, /*# string */ $alias = '') |
||
136 | |||
137 | /** |
||
138 | * Append to existing tables |
||
139 | * |
||
140 | * {@inheritDoc} |
||
141 | */ |
||
142 | public function from($table, /*# string */ $alias = '') |
||
148 | |||
149 | /** |
||
150 | * {@inheritDoc} |
||
151 | */ |
||
152 | public function select()/*# : SelectStatementInterface */ |
||
158 | |||
159 | /** |
||
160 | * {@inheritDoc} |
||
161 | */ |
||
162 | public function insert(array $values = [])/*# : InsertStatementInterface */ |
||
168 | |||
169 | /** |
||
170 | * {@inheritDoc} |
||
171 | */ |
||
172 | public function update(array $values = [])/*# : UpdateStatementInterface */ |
||
178 | |||
179 | /** |
||
180 | * {@inheritDoc} |
||
181 | */ |
||
182 | public function union()/*# : UnionStatementInterface */ |
||
194 | |||
195 | /** |
||
196 | * Convert to [$table => alias] or [$table] |
||
197 | * |
||
198 | * @param string|string[] $table |
||
199 | * @param string $alias |
||
200 | * @return array |
||
201 | * @access protected |
||
202 | */ |
||
203 | protected function fixTable( |
||
214 | |||
215 | /** |
||
216 | * Builder default settings |
||
217 | * |
||
218 | * @return array |
||
219 | * @access protected |
||
220 | */ |
||
221 | protected function defaultSettings()/*# : array */ |
||
233 | } |
||
234 |