1 | <?php |
||
39 | class Builder extends ObjectAbstract implements BuilderInterface |
||
40 | { |
||
41 | use DialectAwareTrait, SettingsTrait, ParameterAwareTrait; |
||
42 | |||
43 | /** |
||
44 | * tables |
||
45 | * |
||
46 | * @var array |
||
47 | * @access protected |
||
48 | */ |
||
49 | protected $tables = []; |
||
50 | |||
51 | /** |
||
52 | * Constructor |
||
53 | * |
||
54 | * ```php |
||
55 | * // builder with default table `users` and Mysql dialect |
||
56 | * $users = new Builder('users', new Mysql()) |
||
57 | * |
||
58 | * // builder with defult tables: `users` and `accounts` AS `a` |
||
59 | * $builder = new Builder(['users', 'accounts' => 'a']) |
||
60 | * |
||
61 | * // change default settings |
||
62 | * $builder = new Builder('users', new Mysql(), ['autoQuote' => false]); |
||
63 | * ``` |
||
64 | * |
||
65 | * @param string|array $table table[s] to build upon |
||
66 | * @param DialectInterface $dialect default dialect is `Mysql` |
||
67 | * @param array $settings builder settings |
||
68 | * @access public |
||
69 | */ |
||
70 | public function __construct( |
||
81 | |||
82 | /** |
||
83 | * Change table[s] |
||
84 | * |
||
85 | * @param $table change to table[s] |
||
86 | * @return $this |
||
87 | * @access public |
||
88 | */ |
||
89 | public function __invoke($table) |
||
93 | |||
94 | /** |
||
95 | * {@inheritDoc} |
||
96 | */ |
||
97 | public function expr()/*# : ExpressionInterface */ |
||
101 | |||
102 | /** |
||
103 | * {@inheritDoc} |
||
104 | */ |
||
105 | public function raw(/*# string */ $string)/*# : RawInterface */ |
||
117 | |||
118 | /** |
||
119 | * If has existing tables, return a new instance with provided table[s] |
||
120 | * |
||
121 | * {@inheritDoc} |
||
122 | */ |
||
123 | public function table($table, /*# string */ $alias = '') |
||
130 | |||
131 | /** |
||
132 | * Append to existing tables |
||
133 | * |
||
134 | * {@inheritDoc} |
||
135 | */ |
||
136 | public function from($table, /*# string */ $alias = '') |
||
142 | |||
143 | /** |
||
144 | * {@inheritDoc} |
||
145 | */ |
||
146 | public function select( |
||
154 | |||
155 | /** |
||
156 | * Convert to [$table => alias] or [$table] |
||
157 | * |
||
158 | * @param string|string[] $table |
||
159 | * @param string $alias |
||
160 | * @return array |
||
161 | * @access protected |
||
162 | */ |
||
163 | protected function fixTable( |
||
174 | |||
175 | /** |
||
176 | * Builder default settings |
||
177 | * |
||
178 | * @return array |
||
179 | * @access protected |
||
180 | */ |
||
181 | protected function defaultSettings()/*# : array */ |
||
206 | } |
||
207 |