$ MYSQL_TYPES = Array (
// INTEGER
// byte - number of bytes in storage,
// max / min - limit values
// umax / umin - unsigned limit values
'int' => Array ( 'byte' => 4, 'min' => - 2147483648, 'max' => 2147483647, 'umin' => 0, 'umax' => 4294967295),
'bigint' => Array ( 'byte' => 8, 'min' => - 9223372036854775808, 'max' => 9223372036854775807, 'umin' => 0, 'umax' => 18446744073709551615),
'tinyint' => Array ( 'byte' => 1, 'min' => - 128, 'max' => 127, 'umin' => 0, 'umax' => 255),
'smallint' => Array ( 'byte' => 2, 'min' => - 32768, 'max' => 32767, 'umin' => 0, 'umax' => 65535),
'mediumint' => Array ( 'byte' => 3, 'min' => - 8388608, 'max' => 8388607, 'umin' => 0, 'umax' => 16777215),
// DECIMAL DECIMAL (M, D) m - number of digits (max 65 digits), d - how many of them can be after comma
// min_byte / max_byte - boundary values of the field size in bytes,
// byte_formula - dimension calculation formula
// length - maximum number of digits
'decimal' => Array ( 'min_byte' => 2, 'max_byte' => 67, 'byte_formula' => '(D == 0? (M + 1) :( M + 2)' , 'length' = > 65)
'dec' => Array ( 'min_byte' => 2, 'max_byte' => 67, 'byte_formula' => 'D == 0? (M + 1) :( M + 2)' , 'length' => 65)
'numeric' => Array ( 'min_byte' => 2, 'max_byte' => 67, 'byte_formula' => 'D == 0? (M + 1) :( M + 2)' , 'length' => 65)
// FLOAT DOUBLE
// Attention! Do not store cash values in these fields !!! Money must be stored - in DECIMAL
// FLOAT ACCURACY ONLY 7 DIGITS !!! (all other numbers are “smeared”)
// DOUBLE ACCURACY ONLY 15 DIGITS !!! (all other numbers are “smeared”)
// byte - number of bytes to store the field (by default)
// max_byte - the maximum number of bytes to store
// negative_min / negative_max - minmax for negative numbers
// positive_min / positive_max - minmax for positive numbers
'float' => Array ( 'byte' => 4, 'max_byte' => 8, 'negative_min' => - 3.402823466E + 38, 'negative_max' => - 1.175494351E-38, 'positive_min' => 1.175494351E -38, 'positive_max' => 3.402823466E + 38)
'double' => Array ( 'byte' => 8, 'negative_min' => - 1.7976931348623157E + 308, 'negative_max' => - 2.2250738585072014E-308, 'positive_min' => 2.2250738585072014E-308, 'positive_max' = > 1.7976931348623157E + 308),
// BOOLEAN
// you will understand everything
'bool' => Array ( 'byte' => 1, 'true' => 1, 'false' => 0),
'boolean' => Array ( 'byte' => 1, 'true' => 1, 'false' => 0),
// VARCHAR
// byte - number of bytes allocated for storage (you can set less)
// min_byte - the minimum number of bytes in which the field can be stored (if the length is 1)
// In MYSQL 5.0.3 and higher, VARCHAR can be up to 65,535 characters !!!
// length - the maximum length of characters in the field
'varchar' => Array ( 'byte' => 256, 'min_byte' => 2, 'length' => 255),
'char' => Array ( 'byte' => 256, 'min_byte' => 2, 'length' => 255),
// TEXT
// byte - number of bytes to store the field
// min_byte - the minimum number of bytes to store one character (if the field length is 1)
// length - the maximum number of characters in the field
'tinytext' => Array ( 'byte' => 256, 'min_byte' => 2, 'length' => 255),
'text' => Array ( 'byte' => 65537, 'min_byte' => 3, 'length' => 65535),
'mediumtext' => Array ( 'byte' => 16777218, 'min_byte' => 4, 'length' => 16777215),
'longtext' => Array ( 'byte' => 4294967300, 'min_byte' => 5, 'length' => 4294967296),
'tinyblob' => Array ( 'byte' => 256, 'min_byte' => 2, 'length' => 255),
'blob' => Array ( 'byte' => 65537, 'min_byte' => 3, 'length' => 65535),
'mediumblob' => Array ( 'byte' => 16777219, 'min_byte' => 4, 'length' => 16777215),
'longblob' => Array ( 'byte' => 4294967300, 'min_byte' => 5, 'length' => 4294967296),
// DATETIME
// byte - number of bytes to store the field value
// mask - standard input value mask (there are a lot of other options, read about them in the manual)
// min / max - the minimum maximum values of dates that save fields
'datetime' => Array ( 'byte' => 8, 'mask' => 'YYYY-MM-DD HH: MM: SS' , 'min' => '1000-01-01 00:00:00' , 'max' => '9999-12-31 23:59:59' ),
'date' => Array ( 'byte' => 3, 'mask' => 'YYYY-MM-DD' , 'min' => '1000-01-01' , 'max' => '9999-12- 31 ' )
'time' => Array ( 'byte' => 3, 'min' => '-838: 59: 59' , 'max' => '838: 59: 59' ),
'year' => Array ( 'byte' => 1, 'min' => 1901, 'max' => 2155),
'timestamp' => Array ( 'byte' => 4, 'mask' => Array (14 => 'YYYYMMDDHHMMSS' , 12 => 'YYMMDDHHMMSS' , 10 => 'YYMMDDHHMM' , 8 => 'YYYMMDD' , 6 => 'YYMMDD' , 4 => 'YYMM' , 2 => 'YY' ), 'min' => 1970, 'max' => 2036),
// ENUM
// byte - number of bytes in the storage field
// max_byte - the maximum number of bytes that can be achieved with the maximum number of elements
// max_number_of_element - number of elements that the field can contain
'enum' => Array ( 'byte' => 1, 'max_byte' => 2, 'max_number_of_element' => 65535),
'set' => Array ( 'byte' => 1, 'max_byte' => 8, 'max_number_of_element' => 64)
); * This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/36868/
All Articles