10/16/2026

Doctrine Field Types in Seven Slides: MySQL to Doctrine

Which Doctrine type does that column become?

This is the lookup version of Doctrine field type mappings: tinyint is a boolean: seven slides, mostly one family of types each. Mappings and PHP types were checked against DBAL 4.5; older versions differ where a slide says so. Use the arrow keys or the Next button. With scripts off, the slides read in order below.

The full article has the full table, the reasoning behind the three mappings worth a second look, and where to check a type not listed.

MySQL to Doctrine types, slide by slide

  1. Doctrine reads MySQL tinyint as boolean whatever its declared length when it reads an existing schema: TINYINT(1), TINYINT(4) and a TINYINT holding 0 to 100 all map to boolean. Mapped as boolean, a stored 50 comes back as true; mapped as smallint, it is the int 50
    Doctrine reads MySQL tinyint as booleanWhen Doctrine reads an existing schema it treats every MySQL tinyint as boolean. This is DBAL's own platform mapping, not a bug, checked against DBAL 4.5.
  2. MySQL number types in Doctrine: smallint to smallint, mediumint int and integer to integer, bigint to bigint, float to smallfloat (DBAL 4.1 and later), double and real to float, decimal and numeric to decimal
    Number typestinyint is the exception: it is boolean, not an integer. float becomes smallfloat from DBAL 4.1.
  3. PHP type Doctrine returns: integer and smallint give int; bigint gives int, or string when the value does not fit; decimal gives string; float and smallfloat give float; boolean gives bool; datetime gives DateTime; json gives a decoded value, usually an array; blob gives a resource; binary gives a string (a resource in DBAL 3)
    What PHP gets backdecimal comes back as a string, and bigint can too. Checked against DBAL 4.5.
  4. MySQL text types in Doctrine: tinytext, mediumtext, longtext and text all map to text; varchar and char map to string
    Text and string typesTINYTEXT and LONGTEXT differ in maximum length, but Doctrine cannot tell them apart.
  5. MySQL date and time types in Doctrine: date to date, datetime and timestamp to datetime, time to time, year to date
    Date and time typestimestamp and datetime both become datetime.
  6. MySQL binary and set types in Doctrine: blob, tinyblob, mediumblob and longblob map to blob, binary and varbinary map to binary, set maps to simple_array
    Binary and set typesbinary and varbinary map to binary, not blob. simple_array is comma-joined text with no escaping, so a value containing a comma breaks it.
  7. Storing a small integer: use Types::SMALLINT for the field (right for a new column; over an existing TINYINT column schema tools see a mismatch), or keep the TINYINT column with columnDefinition 'TINYINT NOT NULL', which schema tools still read as boolean
    Need a small integer?The first is almost always the right one for a new column. Use columnDefinition when the schema is not yours to change.

Where the rest is

The complete mapping table, the columnDefinition trade-offs and the questions this keeps raising are in the full article.

Researched and drafted with AI, then reviewed and edited by the site's editors.