2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * SQL data types definition
8 namespace PMA\libraries
;
11 * Generic class holding type definitions.
18 * Returns list of unary operators.
22 public function getUnaryOperators()
33 * Check whether operator is unary.
35 * @param string $op operator name
39 public function isUnaryOperator($op)
41 return in_array($op, $this->getUnaryOperators());
45 * Returns list of operators checking for NULL.
49 public function getNullOperators()
58 * ENUM search operators
62 public function getEnumOperators()
71 * TEXT search operators
75 public function getTextOperators()
96 * Number search operators
100 public function getNumberOperators()
120 * Returns operators for given type
122 * @param string $type Type of field
123 * @param boolean $null Whether field can be NULL
127 public function getTypeOperators($type, $null)
130 $class = $this->getTypeClass($type);
132 if (strncasecmp($type, 'enum', 4) == 0) {
133 $ret = array_merge($ret, $this->getEnumOperators());
134 } elseif ($class == 'CHAR') {
135 $ret = array_merge($ret, $this->getTextOperators());
137 $ret = array_merge($ret, $this->getNumberOperators());
141 $ret = array_merge($ret, $this->getNullOperators());
148 * Returns operators for given type as html options
150 * @param string $type Type of field
151 * @param boolean $null Whether field can be NULL
152 * @param string $selectedOperator Option to be selected
154 * @return string Generated Html
156 public function getTypeOperatorsHtml($type, $null, $selectedOperator = null)
160 foreach ($this->getTypeOperators($type, $null) as $fc) {
161 if (isset($selectedOperator) && $selectedOperator == $fc) {
162 $selected = ' selected="selected"';
166 $html .= '<option value="' . htmlspecialchars($fc) . '"'
168 . htmlspecialchars($fc) . '</option>';
175 * Returns the data type description.
177 * @param string $type The data type to get a description.
182 public function getTypeDescription($type)
188 * Returns class of a type, used for functions available for type
191 * @param string $type The data type to get a class.
196 public function getTypeClass($type)
202 * Returns array of functions available for a class.
204 * @param string $class The class to get function list.
209 public function getFunctionsClass($class)
215 * Returns array of functions available for a type.
217 * @param string $type The data type to get function list.
222 public function getFunctions($type)
224 $class = $this->getTypeClass($type);
225 return $this->getFunctionsClass($class);
229 * Returns array of all functions available.
234 public function getAllFunctions()
237 $this->getFunctionsClass('CHAR'),
238 $this->getFunctionsClass('NUMBER'),
239 $this->getFunctionsClass('DATE'),
240 $this->getFunctionsClass('UUID')
247 * Returns array of all attributes available.
252 public function getAttributes()
258 * Returns array of all column types available.
263 public function getColumns()
275 * Returns an array of integer types
277 * @return string[] integer types
279 public function getIntegerTypes()
285 * Returns the min and max values of a given integer type
287 * @param string $type integer type
288 * @param boolean $signed whether signed
290 * @return string[] min and max values
292 public function getIntegerRange($type, $signed = true)
294 return array('', '');