diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 35e846724b..bb1a1bb5d6 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -3402,8 +3402,7 @@ function PMA_buildActionTitles() /** * This function processes the datatypes supported by the DB, as specified in * $cfg['ColumnTypes'] and either returns an array (useful for quickly checking - * if a datatype is supported) or an HTML snippet that creates a drop-down - * list. + * if a datatype is supported) or an HTML snippet that creates a drop-down list. * * @param bool $html Whether to generate an html snippet or an array * @param string $selected The value to mark as selected in HTML mode @@ -3423,7 +3422,7 @@ function PMA_getSupportedDatatypes($html = false, $selected = '') $retval .= ""; foreach ($value as $subvalue) { if ($subvalue == $selected) { - $retval .= ""; } else if ($subvalue === '-') { @@ -3431,15 +3430,15 @@ function PMA_getSupportedDatatypes($html = false, $selected = '') $retval .= $subvalue; $retval .= ""; } else { - $retval .= ""; + $retval .= ""; } } $retval .= ''; } else { if ($selected == $value) { - $retval .= ""; + $retval .= ""; } else { - $retval .= ""; + $retval .= ""; } } } @@ -3463,6 +3462,23 @@ function PMA_getSupportedDatatypes($html = false, $selected = '') return $retval; } // end PMA_getSupportedDatatypes() +/** + * This function returns the data type description. + * + * @param string $type The data type to get a description. + * + * @return string + * + */ +function PMA_getDatatypeDescription($type) +{ + $type = strtoupper($type); + $descriptions = PMA_supportedDataTypesDescriptions(); + + return isset($descriptions[$type]) + ? htmlentities($descriptions[$type], ENT_QUOTES) : ''; +} // end PMA_getDatatypeDescription() + /** * Returns a list of datatypes that are not (yet) handled by PMA. * Used by: tbl_change.php and libraries/db_routines.inc.php diff --git a/libraries/data_drizzle.inc.php b/libraries/data_drizzle.inc.php index a1a1bffeab..71cf649398 100644 --- a/libraries/data_drizzle.inc.php +++ b/libraries/data_drizzle.inc.php @@ -226,4 +226,32 @@ if ($cfg['ShowFunctionFields']) { unset($restrict_functions); } // end if +/** + * This function returns datatypes descriptions. + * + * @return array Drizzle datatypes descriptions. + * + */ +function PMA_supportedDataTypesDescriptions() +{ + return array( + 'INTEGER' => __('Most common integer.'), + 'BIGINT' => __('Larger-range integer.'), + 'DECIMAL' => __('Fixed precision number.'), + 'DOUBLE' => __('Systems native double type.'), + 'BOOLEAN' => __('True or false.'), + 'SERIAL' => __('A number is inserted in increasing order as rows are inserted into the table.'), + 'UUID' => __('Stores Universally Unique Identifiers (UUID).'), + 'DATE' => __('Dates only.'), + 'DATETIME' => __('Both date and time.'), + 'TIMESTAMP' => __('Both date and time.'), + 'TIME' => __('Time of day.'), + 'VARCHAR' => __('Variable length data.'), + 'TEXT' => __('Data which is over XXX in size'), + 'VARBINARY' => __('Variable length data.'), + 'BLOB' => __('Data which is over XXX in size. Uses a binary collation for all index usage.'), + 'ENUM' => __('Static lists of strings.'), + ); +} // end PMA_supportedDataTypesDescriptions() + ?> diff --git a/libraries/data_mysql.inc.php b/libraries/data_mysql.inc.php index b3b44f8fa2..bb7c6a7a03 100644 --- a/libraries/data_mysql.inc.php +++ b/libraries/data_mysql.inc.php @@ -287,4 +287,55 @@ if ($cfg['ShowFunctionFields']) { unset($restrict_functions); } // end if +/** + * This function returns datatypes descriptions. + * + * @return array MySQL datatypes descriptions. + * + */ +function PMA_supportedDataTypesDescriptions() +{ + return array( + 'TINYINT' => __('A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.'), + 'SMALLINT' => __('A small integer. The signed range is -32,768 to 32,767. The unsigned range is 0 to 65,535.'), + 'MEDIUMINT' => __('A medium-sized integer. The signed range is -8,388,608 to 8,388,607. The unsigned range is 0 to 16,777,215.'), + 'INT' => __('A normal-size integer. The signed range is -2,147,483,648 to 2,147,483,647. The unsigned range is 0 to 4,294,967,295.'), + 'BIGINT' => __('A large integer. The signed range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. The unsigned range is 0 to 18,446,744,073,709,551,615.'), + 'DECIMAL' => __('A packed "exact" fixed-point number. The maximum number of digits (M) for DECIMAL is 65. The maximum number of supported decimals (D) is 30. If D is omitted, the default is 0. If M is omitted, the default is 10.'), + 'FLOAT' => __('A small (single-precision) floating-point number. Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38.'), + 'DOUBLE' => __('A normal-size (double-precision) floating-point number. Allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.'), + 'REAL' => __('Synonyms for DOUBLE. Exception: If the REAL_AS_FLOAT SQL mode is enabled, REAL is a synonym for FLOAT rather than DOUBLE.'), + 'BIT' => __('A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.'), + 'BOOLEAN' => __('These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values are considered true.'), + 'SERIAL' => __('An alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.'), + 'DATE' => __("A date. The supported range is '1000-01-01' to '9999-12-31'. MySQL displays DATE values in 'YYYY-MM-DD' format, but allows assignment of values to DATE columns using either strings or numbers."), + 'DATETIME' => __("A date and time combination. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. MySQL displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format, but allows assignment of values to DATETIME columns using either strings or numbers."), + 'TIMESTAMP' => __("A timestamp. The range is '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC. TIMESTAMP values are stored as the number of seconds since the epoch ('1970-01-01 00:00:00' UTC)."), + 'TIME' => __("A time. The range is '-838:59:59' to '838:59:59'. MySQL displays TIME values in 'HH:MM:SS' format, but allows assignment of values to TIME columns using either strings or numbers."), + 'YEAR' => __("A year in two-digit or four-digit format. The default is four-digit format. In four-digit format, the allowable values are 1901 to 2155, and 0000. In two-digit format, the allowable values are 70 to 69, representing years from 1970 to 2069."), + 'CHAR' => __('A fixed-length string that is always right-padded with spaces to the specified length when stored. M represents the column length in characters. The range of M is 0 to 255. If M is omitted, the length is 1.'), + 'VARCHAR' => __('A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535.'), + 'TINYTEXT' => __('A TEXT column with a maximum length of 255 (2^8 - 1) characters. Each TINYTEXT value is stored using a one-byte length prefix that indicates the number of bytes in the value.'), + 'TEXT' => __('A TEXT column with a maximum length of 65,535 (2^16 - 1) characters. Each TEXT value is stored using a two-byte length prefix that indicates the number of bytes in the value.'), + 'MEDIUMTEXT' => __('A TEXT column with a maximum length of 16,777,215 (2^24 - 1) characters. Each MEDIUMTEXT value is stored using a three-byte length prefix that indicates the number of bytes in the value.'), + 'LONGTEXT' => __('A TEXT column with a maximum length of 4,294,967,295 or 4GB (2^32 - 1) characters. Each LONGTEXT value is stored using a four-byte length prefix that indicates the number of bytes in the value.'), + 'BINARY' => __('The BINARY type is similar to the CHAR type, but stores binary byte strings rather than non-binary character strings. M represents the column length in bytes.'), + 'VARBINARY' => __('The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than non-binary character strings. M represents the maximum column length in bytes.'), + 'TINYBLOB' => __('A BLOB column with a maximum length of 255 (2^8 - 1) bytes. Each TINYBLOB value is stored using a one-byte length prefix that indicates the number of bytes in the value.'), + 'MEDIUMBLOB' => __('A BLOB column with a maximum length of 16,777,215 (2^24 - 1) bytes. Each MEDIUMBLOB value is stored using a three-byte length prefix that indicates the number of bytes in the value.'), + 'BLOB' => __('A BLOB column with a maximum length of 65,535 (2^16 - 1) bytes. Each BLOB value is stored using a two-byte length prefix that indicates the number of bytes in the value.'), + 'LONGBLOB' => __('A BLOB column with a maximum length of 4,294,967,295 or 4GB (2^32 - 1) bytes. Each LONGBLOB value is stored using a four-byte length prefix that indicates the number of bytes in the value.'), + 'ENUM' => __("An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special '' error value. An ENUM column can have a maximum of 65,535 distinct values."), + 'SET' => __("A set. A string object that can have zero or more values, each of which must be chosen from the list of values 'value1', 'value2', ... A SET column can have a maximum of 64 members."), + 'GEOMETRY' => '', + 'POINT' => __('Constructs a WKB Point using its coordinates.'), + 'LINESTRING' => __('Constructs a WKB LineString value from a number of WKB Point arguments. If any argument is not a WKB Point, the return value is NULL. If the number of Point arguments is less than two, the return value is NULL.'), + 'POLYGON' => __('Constructs a WKB Polygon value from a number of WKB LineString arguments. If any argument does not represent the WKB of a LinearRing (that is, not a closed and simple LineString) the return value is NULL.'), + 'MULTIPOINT' => __('Constructs a WKB MultiPoint value using WKB Point arguments. If any argument is not a WKB Point, the return value is NULL.'), + 'MULTILINESTRING' => __('Constructs a WKB MultiLineString value using WKB LineString arguments. If any argument is not a WKB LineString, the return value is NULL.'), + 'MULTIPOLYGON' => __('Constructs a WKB MultiPolygon value from a set of WKB Polygon arguments. If any argument is not a WKB Polygon, the return value is NULL.'), + 'GEOMETRYCOLLECTION' => __('Constructs a WKB GeometryCollection. If any argument is not a well-formed WKB representation of a geometry, the return value is NULL.'), + ); +} // end PMA_supportedDataTypesDescriptions() + ?>