Propel Column Types

Here are the Propel column types with some example mappings to native database and PHP types. There are also several ways to customize the mapping between these types.

Column Types

Text Types

Propel TypeDescExample Default DB Type (MySQL)Default PHP Native Type
CHARFixed-lenght character dataCHARstring
VARCHARVariable-lenght character dataVARCHARstring
LONGVARCHARLong variable-length character dataTEXTstring
CLOBCharacter LOB (locator object)LONGTEXTstring

Numeric Types

Propel TypeDescExample Default DB Type (MySQL)Default PHP Native Type
NUMERICNumeric dataDECIMALstring (PHP int is limited)
DECIMALDecimal dataDECIMALstring (PHP int is limited)
TINYINTTiny integer TINYINTint
SMALLINTSmall integer SMALLINTint
INTEGERIntegerINTEGERint
BIGINTLarge integerBIGINTstring (PHP int is limited)
REALReal numberREALdouble
FLOATFloating point numberFLOATdouble
DOUBLEFloating point numberDOUBLEdouble

Binary Types

Propel TypeDescExample Default DB Type (MySQL)Default PHP Native Type
BINARYFixed-length binary dataBLOBdouble
VARBINARYVariable-length binary dataMEDIUMBLOBdouble
LONGVARBINARYLong variable-length binary dataLONGBLOBdouble
BLOBBinary LOB (locator object)LONGBLOBstring

Temporal (Date/Time) Types

Propel TypeDescExample Default DB Type (MySQL)Default PHP Native Type
DATEDate (e.g. YYYY-MM-DD)DATEDateTime object
TIMETime (e.g. HH:MM:SS)TIMEDateTime object
TIMESTAMPDate + time (e.g. YYYY-MM-DD HH:MM:SS)TIMESTAMPDateTime object

Legacy Temporal Types

The following Propel 1.2 types are still supported, but are no longer needed with Propel 1.3.

Propel TypeDescExample Default DB Type (MySQL)Default PHP Native Type
BU_DATEPre-/post-epoch date (e.g. 1201-03-02)DATEDateTime object
BU_TIMESTAMPPre-/post-epoch Date + time (e.g. 1201-03-02 12:33:00)TIMESTAMPDateTime object

Customizing Mappings

Specify Column Attributes

You can change the way that Propel maps its own types to native SQL types or to PHP types by overriding the values for a specific column.

For example:

(Overriding PHP type)

<column name="population_served" type="INTEGER" phpType="string"/>

(Overriding SQL type)

<column name="ip_address" type="VARCHAR" sqlType="inet"/>

Using Custom Platform

For overriding the mapping between Propel types and native SQL types, you can create your own Platform class and override the mapping.

For example:

<?php
require_once 'propel/engine/platform/MysqlPlatform .php';
class CustomMysqlPlatform extends MysqlPlatform {

    /**
     * Initializes custom domain mapping.
     */
    protected function initialize()
    {
        parent::initialize();
        $this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "DECIMAL"));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "TEXT"));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BLOB"));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "MEDIUMBLOB"));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONGBLOB"));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "LONGBLOB"));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "LONGTEXT"));
    }
}

You must then specify that mapping in the build.properties for your project:

propel.platform.class = propel.engine.platform.${propel.database}Platform