1 | <?php |
||
42 | class Builder extends ObjectAbstract implements BuilderInterface |
||
43 | { |
||
44 | use DialectAwareTrait, SettingsTrait, ParameterAwareTrait, PreviousTrait; |
||
45 | |||
46 | /** |
||
47 | * tables |
||
48 | * |
||
49 | * @var array |
||
50 | * @access protected |
||
51 | */ |
||
52 | protected $tables = []; |
||
53 | |||
54 | /** |
||
55 | * Constructor |
||
56 | * |
||
57 | * ```php |
||
58 | * // builder with default table `users` and Mysql dialect |
||
59 | * $users = new Builder('users', new Mysql()) |
||
60 | * |
||
61 | * // builder with defult tables: `users` and `accounts` AS `a` |
||
62 | * $builder = new Builder(['users', 'accounts' => 'a']) |
||
63 | * |
||
64 | * // change default settings |
||
65 | * $builder = new Builder('users', new Mysql(), ['autoQuote' => false]); |
||
66 | * ``` |
||
67 | * |
||
68 | * @param string|array $table table[s] to build upon |
||
69 | * @param DialectInterface $dialect default dialect is `Mysql` |
||
70 | * @param array $settings builder settings |
||
71 | * @access public |
||
72 | */ |
||
73 | public function __construct( |
||
84 | |||
85 | /** |
||
86 | * Change table[s] |
||
87 | * |
||
88 | * @param $table change to table[s] |
||
89 | * @return $this |
||
90 | * @access public |
||
91 | */ |
||
92 | public function __invoke($table) |
||
96 | |||
97 | /** |
||
98 | * {@inheritDoc} |
||
99 | */ |
||
100 | public function expr()/*# : ExpressionInterface */ |
||
104 | |||
105 | /** |
||
106 | * {@inheritDoc} |
||
107 | */ |
||
108 | public function raw(/*# string */ $string)/*# : RawInterface */ |
||
119 | |||
120 | /** |
||
121 | * If has existing tables, return a new instance with provided table[s] |
||
122 | * |
||
123 | * {@inheritDoc} |
||
124 | */ |
||
125 | public function table($table, /*# string */ $alias = '') |
||
132 | |||
133 | /** |
||
134 | * Append to existing tables |
||
135 | * |
||
136 | * {@inheritDoc} |
||
137 | */ |
||
138 | public function from($table, /*# string */ $alias = '') |
||
144 | |||
145 | /** |
||
146 | * {@inheritDoc} |
||
147 | */ |
||
148 | public function select( |
||
156 | |||
157 | /** |
||
158 | * Get the statement |
||
159 | * |
||
160 | * @param string $name statement name, such as 'select' |
||
161 | * @access protected |
||
162 | */ |
||
163 | protected function getDialectStatement( |
||
177 | |||
178 | /** |
||
179 | * Convert to [$table => alias] or [$table] |
||
180 | * |
||
181 | * @param string|string[] $table |
||
182 | * @param string $alias |
||
183 | * @return array |
||
184 | * @access protected |
||
185 | */ |
||
186 | protected function fixTable( |
||
197 | |||
198 | /** |
||
199 | * Builder default settings |
||
200 | * |
||
201 | * @return array |
||
202 | * @access protected |
||
203 | */ |
||
204 | protected function defaultSettings()/*# : array */ |
||
216 | } |
||
217 |