2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * holds the database index columns class
8 namespace PMA\libraries
;
11 * Index column wrapper
18 * @var string The column name
23 * @var integer The column sequence number in the index, starting with 1.
25 private $_seq_in_index = 1;
28 * @var string How the column is sorted in the index. “A” (Ascending) or
31 private $_collation = null;
34 * The number of indexed characters if the column is only partly indexed,
35 * NULL if the entire column is indexed.
39 private $_sub_part = null;
42 * Contains YES if the column may contain NULL.
43 * If not, the column contains NO.
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.
58 private $_cardinality = null;
63 * @param array $params an array containing the parameters of the index column
65 public function __construct($params = array())
71 * Sets parameters of the index column
73 * @param array $params an array containing the parameters of the index column
77 public function set($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'];
100 * Returns the column name
102 * @return string column name
104 public function getName()
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)
140 if (!$this->_null ||
$this->_null
== 'NO') {
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
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()
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
,