1 | <?php |
||
26 | class Table implements \JsonSerializable, \IteratorAggregate, TableInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $name = ''; |
||
32 | |||
33 | /** |
||
34 | * @var Database |
||
35 | */ |
||
36 | protected $database = null; |
||
37 | |||
38 | /** |
||
39 | * @param Database $database Parent DBAL database. |
||
40 | * @param string $name Table name without prefix. |
||
41 | */ |
||
42 | public function __construct(Database $database, $name) |
||
47 | |||
48 | /** |
||
49 | * Related table database. |
||
50 | * |
||
51 | * @return Database |
||
52 | */ |
||
53 | public function database() |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | * |
||
61 | * @return AbstractTable |
||
62 | */ |
||
63 | public function schema() |
||
70 | |||
71 | /** |
||
72 | * Check if table exists. |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function exists() |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | public function getName() |
||
88 | |||
89 | /** |
||
90 | * Real table name, will include database prefix. |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | public function realName() |
||
98 | |||
99 | /** |
||
100 | * Get list of column names associated with their abstract types. |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | public function getColumns() |
||
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | public function truncate() |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | public function insert(array $rowset = []) |
||
129 | |||
130 | /** |
||
131 | * Perform batch insert into table, every rowset should have identical amount of values matched |
||
132 | * with column names provided in first argument. Method will return lastInsertID on success. |
||
133 | * |
||
134 | * Example: |
||
135 | * $table->insert(["name", "balance"], array(["Bob", 10], ["Jack", 20])) |
||
136 | * |
||
137 | * @param array $columns Array of columns. |
||
138 | * @param array $rowsets Array of rowsets. |
||
139 | * @return mixed |
||
140 | */ |
||
141 | public function batchInsert(array $columns = [], array $rowsets = []) |
||
145 | |||
146 | /** |
||
147 | * Get SelectQuery builder with pre-populated from tables. |
||
148 | * |
||
149 | * @param string $columns |
||
150 | * @return SelectQuery |
||
151 | */ |
||
152 | public function select($columns = '*') |
||
156 | |||
157 | /** |
||
158 | * Get DeleteQuery builder with pre-populated table name. This is NOT table delete method, use |
||
159 | * schema()->drop() for this purposes. If you want to remove all records from table use |
||
160 | * Table->truncate() method. Call ->run() to perform query. |
||
161 | * |
||
162 | * @param array $where Initial set of where rules specified as array. |
||
163 | * @return DeleteQuery |
||
164 | */ |
||
165 | public function delete(array $where = []) |
||
169 | |||
170 | /** |
||
171 | * Get UpdateQuery builder with pre-populated table name and set of columns to update. Columns |
||
172 | * can be scalar values, Parameter objects or even SQLFragments. Call ->run() to perform query. |
||
173 | * |
||
174 | * @param array $values Initial set of columns associated with values. |
||
175 | * @param array $where Initial set of where rules specified as array. |
||
176 | * @return UpdateQuery |
||
177 | */ |
||
178 | public function update(array $values = [], array $where = []) |
||
182 | |||
183 | /** |
||
184 | * Count number of records in table. |
||
185 | * |
||
186 | * @return int |
||
187 | */ |
||
188 | public function count() |
||
192 | |||
193 | /** |
||
194 | * Retrieve an external iterator, SelectBuilder will return QueryResult as iterator. |
||
195 | * |
||
196 | * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
||
197 | * @return SelectQuery |
||
198 | */ |
||
199 | public function getIterator() |
||
203 | |||
204 | /** |
||
205 | * A simple alias for table query without condition. |
||
206 | * |
||
207 | * @return QueryResult |
||
208 | */ |
||
209 | public function all() |
||
213 | |||
214 | /** |
||
215 | * {@inheritdoc} |
||
216 | */ |
||
217 | public function jsonSerialize() |
||
221 | |||
222 | /** |
||
223 | * Bypass call to SelectQuery builder. |
||
224 | * |
||
225 | * @param string $method |
||
226 | * @param array $arguments |
||
227 | * @return SelectQuery |
||
228 | */ |
||
229 | public function __call($method, array $arguments) |
||
233 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.