Getting started - Setting table definition - Data types and lengths.php 1.72 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>
16
        <ul> </ul>
zYne's avatar
zYne committed
17
    <li /><b> timestamp </b>
doctrine's avatar
doctrine committed
18 19 20 21 22
        <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
23
    <li /><b> date </b>
doctrine's avatar
doctrine committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37
        <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
38
<br \>