1 <?php
2
3 4 5 6 7 8 9
10 class rex_sql_index
11 {
12 const INDEX = 'INDEX';
13 const UNIQUE = 'UNIQUE';
14 const FULLTEXT = 'FULLTEXT';
15
16 private $name;
17 private $type;
18 private $columns;
19
20 private $modified = false;
21
22 23 24 25 26
27 public function __construct($name, array $columns, $type = self::INDEX)
28 {
29 $this->name = $name;
30 $this->columns = $columns;
31 $this->type = $type;
32 }
33
34 35 36 37 38
39 public function setModified($modified)
40 {
41 $this->modified = $modified;
42
43 return $this;
44 }
45
46 47 48
49 public function isModified()
50 {
51 return $this->modified;
52 }
53
54 55 56 57 58
59 public function setName($name)
60 {
61 $this->name = $name;
62
63 return $this->setModified(true);
64 }
65
66 67 68
69 public function getName()
70 {
71 return $this->name;
72 }
73
74 75 76 77 78
79 public function setType($type)
80 {
81 $this->type = $type;
82
83 return $this->setModified(true);
84 }
85
86 87 88
89 public function getType()
90 {
91 return $this->type;
92 }
93
94 95 96 97 98
99 public function setColumns(array $columns)
100 {
101 $this->columns = $columns;
102
103 return $this->setModified(true);
104 }
105
106 107 108
109 public function getColumns()
110 {
111 return $this->columns;
112 }
113
114 115 116
117 public function equals(self $index)
118 {
119 return
120 $this->name === $index->name &&
121 $this->type === $index->type &&
122 $this->columns == $index->columns;
123 }
124 }
125