Integer
Last updated on
11 February 2018
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
Int field type is used for storing integers, such as node IDs and user IDs.
Sample Code:
$field['fieldname'] = array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'small', // tiny / small / medium / normal / big
'not null' => TRUE,
'description' => t('Field fieldname of tablename.'),
)MySQL field mappings in the schema.inc file:
'int:tiny' => 'TINYINT',
'int:small' => 'SMALLINT',
'int:medium' => 'MEDIUMINT',
'int:big' => 'BIGINT',
'int:normal' => 'INT',Size key takes one of tiny, small, medium, normal or big as value.
Storage requirements and Maximum Values:
Type Storage Minimum Value Maximum Value
(Bytes) (Signed/Unsigned) (Signed/Unsigned)
TINY: SIGNED 1 -128 127
TINY: UNSIGNED 0 255
SMALL:SIGNED 2 -32768 32767
SMALL: UNSIGNED 0 65535
MEDIUM: SIGNED 3 -8388608 8388607
MEDIUM: UNSIGNED 0 16777215
NORMAL: SIGNED 4 -2147483648 2147483647
NORMAL: UNSIGNED 0 4294967295
BIG: SIGNED 8 -9223372036854775808 9223372036854775807
BIG: UNSIGNED 0 18446744073709551615Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion