Changes between Initial Version and Version 1 of Documentation/1.3/ColumnTypes


Ignore:
Timestamp:
02.03.2007 21:44:34 (4 years ago)
Author:
hans
Comment:

Added column types page (finally!)

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/1.3/ColumnTypes

    v1 v1  
     1 
     2= Propel Column Types = 
     3 
     4Here 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. 
     5 
     6== Column Types == 
     7 
     8=== Text Types === 
     9 
     10||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| 
     11||CHAR||Fixed-lenght character data||CHAR||string|| 
     12||VARCHAR||Variable-lenght character data||VARCHAR||string|| 
     13||LONGVARCHAR||Long variable-length character data||TEXT||string|| 
     14||CLOB||Character LOB (locator object)||LONGTEXT||string|| 
     15 
     16=== Numeric Types === 
     17 
     18||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| 
     19||NUMERIC||Numeric data||DECIMAL||string (PHP int is limited)|| 
     20||DECIMAL||Decimal data||DECIMAL||string (PHP int is limited)|| 
     21||TINYINT||Tiny integer ||TINYINT||int|| 
     22||SMALLINT||Small integer ||SMALLINT||int|| 
     23||INTEGER||Integer||INTEGER||int|| 
     24||BIGINT||Large integer||BIGINT||string (PHP int is limited)|| 
     25||REAL||Real number||REAL||double|| 
     26||FLOAT||Floating point number||FLOAT||double|| 
     27||DOUBLE||Floating point number||DOUBLE||double|| 
     28 
     29=== Binary Types === 
     30 
     31||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| 
     32||BINARY||Fixed-length binary data||BLOB||double|| 
     33||VARBINARY||Variable-length binary data||MEDIUMBLOB||double|| 
     34||LONGVARBINARY||Long variable-length binary data||LONGBLOB||double|| 
     35||BLOB||Binary LOB (locator object)||LONGBLOB||string|| 
     36 
     37=== Temporal (Date/Time) Types === 
     38 
     39 
     40||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| 
     41||DATE||Date (e.g. YYYY-MM-DD)||DATE||DateTime object|| 
     42||TIME||Time (e.g. HH:MM:SS)||TIME||DateTime object|| 
     43||TIMESTAMP||Date + time (e.g. YYYY-MM-DD HH:MM:SS)||TIMESTAMP||DateTime object|| 
     44 
     45==== Legacy Temporal Types ==== 
     46 
     47The following Propel 1.2 types are still supported, but are no longer needed with Propel 1.3. 
     48 
     49||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| 
     50||BU_DATE||Pre-/post-epoch date (e.g. 1201-03-02)||DATE||DateTime object|| 
     51||BU_TIMESTAMP||Pre-/post-epoch Date + time (e.g. 1201-03-02 12:33:00)||TIMESTAMP||DateTime object|| 
     52 
     53== Customizing Mappings == 
     54 
     55=== Specify Column Attributes === 
     56 
     57You 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. 
     58 
     59For example: 
     60 
     61(Overriding PHP type) 
     62{{{ 
     63#!xml 
     64<column name="population_served" type="INTEGER" phpType="string"/> 
     65}}} 
     66 
     67(Overriding SQL type) 
     68{{{ 
     69#!xml 
     70<column name="ip_address" type="VARCHAR" sqlType="inet"/> 
     71}}} 
     72 
     73=== Using Custom Platform === 
     74 
     75For overriding the mapping between Propel types and native SQL types, you can create your own Platform class and override the mapping. 
     76 
     77For example: 
     78 
     79{{{ 
     80#!php 
     81<?php 
     82require_once 'propel/engine/platform/MysqlPlatform .php'; 
     83class CustomMysqlPlatform extends MysqlPlatform { 
     84 
     85        /** 
     86         * Initializes custom domain mapping. 
     87         */ 
     88        protected function initialize() 
     89        { 
     90                parent::initialize(); 
     91                $this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "DECIMAL")); 
     92                $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "TEXT")); 
     93                $this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BLOB")); 
     94                $this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "MEDIUMBLOB")); 
     95                $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONGBLOB")); 
     96                $this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "LONGBLOB")); 
     97                $this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "LONGTEXT")); 
     98        } 
     99} 
     100}}} 
     101 
     102You must then specify that mapping in the {{{build.properties}}} for your project: 
     103 
     104{{{ 
     105propel.platform.class = propel.engine.platform.${propel.database}Platform 
     106}}}