1: <?php
2:
3: namespace webfilesframework\core\datasystem\database;
4: use webfilesframework\MWebfilesFrameworkException;
5:
6: 7: 8: 9: 10: 11:
12: class MDatabaseTableColumn
13: {
14:
15: var $name;
16: var $type;
17: var $length;
18:
19: 20: 21: 22: 23:
24: public function __construct($name, $type, $length = null)
25: {
26: $this->name = $name;
27: $this->type = $type;
28: $this->length = $length;
29: }
30:
31: 32: 33: 34:
35: public function getStringRepresentation()
36: {
37:
38: if ($this->type == MDatabaseDatatypes::VARCHAR) {
39: return "`" . $this->name . "` varchar(" . $this->length . ") CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,";
40: } elseif ($this->type == MDatabaseDatatypes::TEXT) {
41: return "`" . $this->name . "` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,";
42: } elseif ($this->type == MDatabaseDatatypes::INT) {
43: return "`" . $this->name . "` int(" . $this->length . ") NOT NULL,";
44: } else {
45: throw new MWebfilesFrameworkException("Unknown Datatype: " . $this->type);
46: }
47: }
48:
49: }
50: