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 Type | Desc | Example Default DB Type (MySQL) | Default PHP Native Type |
| CHAR | Fixed-lenght character data | CHAR | string |
| VARCHAR | Variable-lenght character data | VARCHAR | string |
| LONGVARCHAR | Long variable-length character data | TEXT | string |
| CLOB | Character LOB (locator object) | LONGTEXT | string |
Numeric Types
| Propel Type | Desc | Example Default DB Type (MySQL) | Default PHP Native Type |
| NUMERIC | Numeric data | DECIMAL | string (PHP int is limited) |
| DECIMAL | Decimal data | DECIMAL | string (PHP int is limited) |
| TINYINT | Tiny integer | TINYINT | int |
| SMALLINT | Small integer | SMALLINT | int |
| INTEGER | Integer | INTEGER | int |
| BIGINT | Large integer | BIGINT | string (PHP int is limited) |
| REAL | Real number | REAL | double |
| FLOAT | Floating point number | FLOAT | double |
| DOUBLE | Floating point number | DOUBLE | double |
Binary Types
| Propel Type | Desc | Example Default DB Type (MySQL) | Default PHP Native Type |
| BINARY | Fixed-length binary data | BLOB | double |
| VARBINARY | Variable-length binary data | MEDIUMBLOB | double |
| LONGVARBINARY | Long variable-length binary data | LONGBLOB | double |
| BLOB | Binary LOB (locator object) | LONGBLOB | string |
Temporal (Date/Time) Types
| Propel Type | Desc | Example Default DB Type (MySQL) | Default PHP Native Type |
| DATE | Date (e.g. YYYY-MM-DD) | DATE | DateTime object |
| TIME | Time (e.g. HH:MM:SS) | TIME | DateTime object |
| TIMESTAMP | Date + time (e.g. YYYY-MM-DD HH:MM:SS) | TIMESTAMP | DateTime object |
Legacy Temporal Types
The following Propel 1.2 types are still supported, but are no longer needed with Propel 1.3.
| Propel Type | Desc | Example Default DB Type (MySQL) | Default PHP Native Type |
| BU_DATE | Pre-/post-epoch date (e.g. 1201-03-02) | DATE | DateTime object |
| BU_TIMESTAMP | Pre-/post-epoch Date + time (e.g. 1201-03-02 12:33:00) | TIMESTAMP | DateTime 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
