Fix #15621 - Support CloudFront-Forwarded-Proto header
[phpmyadmin.git] / libraries / classes / IndexColumn.php
blob00a2b7babaddb604fa5840f621ae4048848dfc6b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * holds the database index columns class
6 * @package PhpMyAdmin
7 */
8 namespace PhpMyAdmin;
10 /**
11 * Index column wrapper
13 * @package PhpMyAdmin
15 class IndexColumn
17 /**
18 * @var string The column name
20 private $_name = '';
22 /**
23 * @var integer The column sequence number in the index, starting with 1.
25 private $_seq_in_index = 1;
27 /**
28 * @var string How the column is sorted in the index. “A” (Ascending) or
29 * NULL (Not sorted)
31 private $_collation = null;
33 /**
34 * The number of indexed characters if the column is only partly indexed,
35 * NULL if the entire column is indexed.
37 * @var integer
39 private $_sub_part = null;
41 /**
42 * Contains YES if the column may contain NULL.
43 * If not, the column contains NO.
45 * @var string
47 private $_null = '';
49 /**
50 * An estimate of the number of unique values in the index. This is updated
51 * by running ANALYZE TABLE or myisamchk -a. Cardinality is counted based on
52 * statistics stored as integers, so the value is not necessarily exact even
53 * for small tables. The higher the cardinality, the greater the chance that
54 * MySQL uses the index when doing joins.
56 * @var integer
58 private $_cardinality = null;
60 /**
61 * Constructor
63 * @param array $params an array containing the parameters of the index column
65 public function __construct(array $params = array())
67 $this->set($params);
70 /**
71 * Sets parameters of the index column
73 * @param array $params an array containing the parameters of the index column
75 * @return void
77 public function set(array $params)
79 if (isset($params['Column_name'])) {
80 $this->_name = $params['Column_name'];
82 if (isset($params['Seq_in_index'])) {
83 $this->_seq_in_index = $params['Seq_in_index'];
85 if (isset($params['Collation'])) {
86 $this->_collation = $params['Collation'];
88 if (isset($params['Cardinality'])) {
89 $this->_cardinality = $params['Cardinality'];
91 if (isset($params['Sub_part'])) {
92 $this->_sub_part = $params['Sub_part'];
94 if (isset($params['Null'])) {
95 $this->_null = $params['Null'];
99 /**
100 * Returns the column name
102 * @return string column name
104 public function getName()
106 return $this->_name;
110 * Return the column collation
112 * @return string column collation
114 public function getCollation()
116 return $this->_collation;
120 * Returns the cardinality of the column
122 * @return int cardinality of the column
124 public function getCardinality()
126 return $this->_cardinality;
130 * Returns whether the column is nullable
132 * @param boolean $as_text whether to returned the string representation
134 * @return mixed nullability of the column. True/false or Yes/No depending
135 * on the value of the $as_text parameter
137 public function getNull($as_text = false)
139 if ($as_text) {
140 if (!$this->_null || $this->_null == 'NO') {
141 return __('No');
144 return __('Yes');
147 return $this->_null;
151 * Returns the sequence number of the column in the index
153 * @return int sequence number of the column in the index
155 public function getSeqInIndex()
157 return $this->_seq_in_index;
161 * Returns the number of indexed characters if the column is only
162 * partly indexed
164 * @return int the number of indexed characters
166 public function getSubPart()
168 return $this->_sub_part;
172 * Gets the properties in an array for comparison purposes
174 * @return array an array containing the properties of the index column
176 public function getCompareData()
178 return array(
179 'Column_name' => $this->_name,
180 'Seq_in_index' => $this->_seq_in_index,
181 'Collation' => $this->_collation,
182 'Sub_part' => $this->_sub_part,
183 'Null' => $this->_null,