Getting started - Setting table definition - Data types and lengths.php 1.94 KB
Newer Older
doctrine's avatar
doctrine committed
1 2
Following data types are availible in doctrine:
    <ul>
zYne's avatar
zYne committed
3
    <li /><b> string </b>
doctrine's avatar
doctrine committed
4
        <dd /> The same as type 'string' in php
zYne's avatar
zYne committed
5
    <li /><b> float / double</b>
doctrine's avatar
doctrine committed
6
        <dd /> The same as type 'float' in php<br />
zYne's avatar
zYne committed
7
    <li /><b> integer</b>
doctrine's avatar
doctrine committed
8
        <dd /> The same as type 'integer' in php<br />
zYne's avatar
zYne committed
9
    <li /><b> boolean </b>
doctrine's avatar
doctrine committed
10
        <dd /> The same as type 'boolean' in php<br />
zYne's avatar
zYne committed
11
    <li /><b> array </b>
doctrine's avatar
doctrine committed
12
        <ul> The same as type 'array' in php. Automatically serialized when saved into database and unserialized when retrieved from database.</ul>
zYne's avatar
zYne committed
13
    <li /><b> object </b>
doctrine's avatar
doctrine committed
14
        <ul> The same as type 'object' in php. Automatically serialized when saved into database and unserialized when retrieved from database.</ul>
zYne's avatar
zYne committed
15
    <li /><b> enum </b>
doctrine's avatar
doctrine committed
16 17
        <ul> Unified 'enum' type. Automatically converts the string values into index numbers and vice versa. The possible values for the column 
        can be specified with Doctrine_Record::setEnumValues(columnName, array values).</ul>
zYne's avatar
zYne committed
18
    <li /><b> timestamp </b>
doctrine's avatar
doctrine committed
19 20 21 22 23
        <dd /> Database 'timestamp' type
    <li /><b> clob</b>
        <dd /> Database 'clob' type
    <li /><b> blob</b>
        <dd /> Database 'blob' type
zYne's avatar
zYne committed
24
    <li /><b> date </b>
doctrine's avatar
doctrine committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38
        <dd /> Database 'date' type
    </ul>

It should be noted that the length of the column affects in database level type
as well as application level validated length (the length that is validated with Doctrine validators).<br \>

<br \>Example 1. Column named 'content' with type 'string' and length 3000 results in database type 'TEXT' of which has database level length of 4000.
However when the record is validated it is only allowed to have 'content' -column with maximum length of 3000.<br \>

<br \>Example 2. Column with type 'integer' and length 1 results in 'TINYINT' on many databases. 
<br \><br \>

In general Doctrine is smart enough to know which integer/string type to use depending on the specified length.

zYne's avatar
zYne committed
39
<br \>