1 | <?php |
||
13 | class Column |
||
14 | { |
||
15 | /** |
||
16 | * @var boolean |
||
17 | */ |
||
18 | protected $autoIncrement = false; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $dataType; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $defaultValue = ''; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $field; |
||
34 | |||
35 | /** |
||
36 | * @var boolean |
||
37 | */ |
||
38 | protected $foreign = false; |
||
39 | |||
40 | /** |
||
41 | * @var integer |
||
42 | */ |
||
43 | protected $length = 0; |
||
44 | |||
45 | /** |
||
46 | * @var boolean |
||
47 | */ |
||
48 | protected $null = false; |
||
49 | |||
50 | /** |
||
51 | * @var boolean |
||
52 | */ |
||
53 | protected $primary = false; |
||
54 | |||
55 | /** |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $referencedField; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $referencedTable; |
||
64 | |||
65 | /** |
||
66 | * @var boolean |
||
67 | */ |
||
68 | protected $unique = false; |
||
69 | |||
70 | /** |
||
71 | * @var boolean |
||
72 | */ |
||
73 | protected $unsigned = false; |
||
74 | |||
75 | /** |
||
76 | * Gets the data type. |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | 3 | public function getDataType() |
|
81 | { |
||
82 | 3 | return $this->dataType; |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * Gets the default value. |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | 3 | public function getDefaultValue() |
|
91 | { |
||
92 | 3 | return $this->defaultValue; |
|
93 | } |
||
94 | |||
95 | /** |
||
96 | * Gets the column description. |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | 12 | public function getField() |
|
101 | { |
||
102 | 12 | return $this->field; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * Gets the foreign field. |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | 3 | public function getReferencedField() |
|
111 | { |
||
112 | 3 | return $this->referencedField; |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * Gets the foreign table. |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | 3 | public function getReferencedTable() |
|
121 | { |
||
122 | 3 | return $this->referencedTable; |
|
123 | } |
||
124 | |||
125 | /** |
||
126 | * Gets the field's length. |
||
127 | * |
||
128 | * @return integer |
||
129 | */ |
||
130 | 3 | public function getLength() |
|
131 | { |
||
132 | 3 | return $this->length; |
|
133 | } |
||
134 | |||
135 | /** |
||
136 | * Gets the data type. |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 3 | public function get_data_type() |
|
141 | { |
||
142 | 3 | return $this->dataType; |
|
143 | } |
||
144 | |||
145 | /** |
||
146 | * Gets the default value. |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | 3 | public function get_default_value() |
|
151 | { |
||
152 | 3 | return $this->defaultValue; |
|
153 | } |
||
154 | |||
155 | /** |
||
156 | * Gets the column description. |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | 12 | public function get_field() |
|
164 | |||
165 | /** |
||
166 | * Gets the foreign field. |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | 3 | public function get_referenced_field() |
|
171 | { |
||
172 | 3 | return $this->referencedField; |
|
173 | } |
||
174 | |||
175 | /** |
||
176 | * Gets the foreign table. |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | 3 | public function get_referenced_table() |
|
181 | { |
||
182 | 3 | return $this->referencedTable; |
|
183 | } |
||
184 | |||
185 | /** |
||
186 | * Gets the field's length. |
||
187 | * |
||
188 | * @return string |
||
189 | */ |
||
190 | 3 | public function get_length() |
|
191 | { |
||
192 | 3 | return $this->length; |
|
193 | } |
||
194 | |||
195 | /** |
||
196 | * Check if the field is an auto incrementing field |
||
197 | * |
||
198 | * @return boolean |
||
199 | */ |
||
200 | 3 | public function isAutoIncrement() |
|
201 | { |
||
202 | 3 | return $this->autoIncrement; |
|
203 | } |
||
204 | |||
205 | /** |
||
206 | * Check if the field is a foreign key |
||
207 | * |
||
208 | * @return boolean |
||
209 | */ |
||
210 | 3 | public function isForeignKey() |
|
211 | { |
||
212 | 3 | return $this->foreign; |
|
213 | } |
||
214 | |||
215 | /** |
||
216 | * Check if the field accept NULL values |
||
217 | * |
||
218 | * @return boolean |
||
219 | */ |
||
220 | 3 | public function isNull() |
|
221 | { |
||
222 | 3 | return $this->null; |
|
223 | } |
||
224 | |||
225 | /** |
||
226 | * Check if the field is a primary key |
||
227 | * |
||
228 | * @return boolean |
||
229 | */ |
||
230 | 15 | public function isPrimaryKey() |
|
234 | |||
235 | /** |
||
236 | * Check if field is unique |
||
237 | * |
||
238 | * @return boolean |
||
239 | */ |
||
240 | 3 | public function isUnique() |
|
241 | { |
||
242 | 3 | return $this->unique; |
|
243 | } |
||
244 | |||
245 | /** |
||
246 | * Check if field is unsigned |
||
247 | * |
||
248 | * @return boolean |
||
249 | */ |
||
250 | 3 | public function isUnsigned() |
|
251 | { |
||
252 | 3 | return $this->unsigned; |
|
253 | } |
||
254 | |||
255 | /** |
||
256 | * Check if the field is an auto incrementing field |
||
257 | * |
||
258 | * @return boolean |
||
259 | */ |
||
260 | 3 | public function is_auto_increment() |
|
261 | { |
||
262 | 3 | return $this->autoIncrement; |
|
263 | } |
||
264 | |||
265 | /** |
||
266 | * Check if the field is a foreign key |
||
267 | * |
||
268 | * @return boolean |
||
269 | */ |
||
270 | 3 | public function is_foreign_key() |
|
271 | { |
||
272 | 3 | return $this->foreign; |
|
273 | } |
||
274 | |||
275 | /** |
||
276 | * Check if the field accept NULL values |
||
277 | * |
||
278 | * @return boolean |
||
279 | */ |
||
280 | 3 | public function is_null() |
|
281 | { |
||
282 | 3 | return $this->null; |
|
283 | } |
||
284 | |||
285 | /** |
||
286 | * Check if the field is a primary key |
||
287 | * |
||
288 | * @return boolean |
||
289 | */ |
||
290 | 3 | public function is_primary_key() |
|
291 | { |
||
292 | 3 | return $this->primary; |
|
293 | } |
||
294 | |||
295 | /** |
||
296 | * Check if field is unique |
||
297 | * |
||
298 | * @return boolean |
||
299 | */ |
||
300 | 3 | public function is_unique() |
|
301 | { |
||
302 | 3 | return $this->unique; |
|
303 | } |
||
304 | |||
305 | /** |
||
306 | * Check if field is unsigned |
||
307 | * |
||
308 | * @return boolean |
||
309 | */ |
||
310 | 3 | public function is_unsigned() |
|
311 | { |
||
312 | 3 | return $this->unsigned; |
|
313 | } |
||
314 | |||
315 | /** |
||
316 | * Sets the auto increment. |
||
317 | * |
||
318 | * @param boolean $autoIncrement |
||
319 | */ |
||
320 | 57 | public function setAutoIncrement($autoIncrement) |
|
326 | |||
327 | /** |
||
328 | * Sets the data type. |
||
329 | * |
||
330 | * @param string $dataType |
||
331 | */ |
||
332 | 57 | public function setDataType($dataType) |
|
348 | |||
349 | /** |
||
350 | * Sets the default value. |
||
351 | * |
||
352 | * @param string $defaultValue |
||
353 | */ |
||
354 | 57 | public function setDefaultValue($defaultValue) |
|
360 | |||
361 | /** |
||
362 | * Sets the column's description. |
||
363 | * |
||
364 | * @param string $field |
||
365 | */ |
||
366 | 57 | public function setField($field) |
|
372 | |||
373 | /** |
||
374 | * Sets the field as a foreign key. |
||
375 | * |
||
376 | * @param boolean $foreign |
||
377 | */ |
||
378 | 57 | public function setForeign($foreign) |
|
379 | { |
||
380 | 57 | $this->foreign = $foreign; |
|
381 | |||
382 | 57 | return $this; |
|
383 | } |
||
384 | |||
385 | /** |
||
386 | * Sets the foreign field. |
||
387 | * |
||
388 | * @param string $referencedField |
||
389 | */ |
||
390 | 57 | public function setReferencedField($referencedField) |
|
391 | { |
||
392 | 57 | $this->referencedField = $referencedField; |
|
393 | |||
394 | 57 | return $this; |
|
395 | } |
||
396 | |||
397 | /** |
||
398 | * Sets the foreign table. |
||
399 | * |
||
400 | * @param string $foreignTable |
||
401 | */ |
||
402 | 57 | public function setReferencedTable($foreignTable) |
|
403 | { |
||
404 | 57 | $this->referencedTable = $foreignTable; |
|
405 | |||
406 | 57 | return $this; |
|
407 | } |
||
408 | |||
409 | /** |
||
410 | * Sets the field's length. |
||
411 | * |
||
412 | * @param integer $length |
||
413 | */ |
||
414 | 45 | public function setLength($length) |
|
415 | { |
||
416 | 45 | $this->length = $length; |
|
417 | |||
418 | 45 | return $this; |
|
419 | } |
||
420 | |||
421 | /** |
||
422 | * Sets if field accepts NULL values. |
||
423 | * |
||
424 | * @param boolean $null |
||
425 | */ |
||
426 | 57 | public function setNull($null = true) |
|
432 | |||
433 | /** |
||
434 | * Sets if field is a primary key. |
||
435 | * |
||
436 | * @param boolean $primary |
||
437 | */ |
||
438 | 57 | public function setPrimary($primary = true) |
|
444 | |||
445 | /** |
||
446 | * Sets if field is a unique key. |
||
447 | * |
||
448 | * @param boolean $unique |
||
449 | */ |
||
450 | 45 | public function setUnique($unique = true) |
|
451 | { |
||
452 | 45 | $this->unique = $unique; |
|
453 | |||
454 | 45 | return $this; |
|
455 | } |
||
456 | |||
457 | /** |
||
458 | * Sets if field is an unsigned key. |
||
459 | * |
||
460 | * @param boolean $unsigned |
||
461 | */ |
||
462 | 3 | public function setUnsigned($unsigned = true) |
|
463 | { |
||
464 | 3 | $this->unsigned = $unsigned; |
|
465 | |||
466 | 3 | return $this; |
|
467 | } |
||
468 | } |
||
469 |