Zend Basic Tutorial
Zend Forms
Zend Database
Zend Advanced
|
Doctrine Type |
Column Type in DB |
Example Annotation |
Description |
|---|---|---|---|
|
string |
VARCHAR |
@ORM\Column(type="string", length=255) |
A string up to a defined length |
|
text |
TEXT |
@ORM\Column(type="text") |
Longer text field |
|
integer |
INT |
@ORM\Column(type="integer") |
Standard integer |
|
smallint |
SMALLINT |
@ORM\Column(type="smallint") |
Small integer |
|
bigint |
BIGINT |
@ORM\Column(type="bigint") |
Big integer |
|
boolean |
BOOLEAN |
@ORM\Column(type="boolean") |
True/False value |
|
decimal |
DECIMAL |
@ORM\Column(type="decimal", precision=10, scale=2) |
Fixed-precision number |
|
float |
FLOAT |
@ORM\Column(type="float") |
Floating-point number |
|
date |
DATE |
@ORM\Column(type="date") |
Date only (Y-m-d) |
|
datetime |
DATETIME |
@ORM\Column(type="datetime") |
Date + Time (Y-m-d H:i:s) |
|
datetimetz |
DATETIME w/ timezone |
@ORM\Column(type="datetimetz") |
DateTime with time zone |
|
time |
TIME |
@ORM\Column(type="time") |
Time only (H:i:s) |
|
array |
TEXT (serialized) |
@ORM\Column(type="array") |
PHP array (stored serialized) |
|
json |
JSON |
@ORM\Column(type="json") |
Native JSON (if DB supports) |
|
object |
TEXT (serialized) |
@ORM\Column(type="object") |
PHP object (serialized) |
|
simple_array |
VARCHAR (CSV) |
@ORM\Column(type="simple_array") |
CSV string → PHP array |
|
guid |
UUID/GUID |
@ORM\Column(type="guid") |
Globally unique identifier |
|
binary |
BLOB |
@ORM\Column(type="binary") |
Binary data (e.g., file blob) |
|
blob |
BLOB |
@ORM\Column(type="blob") |
Binary large object |
|
enum(custom) |
ENUM |
❌ Must define manually as custom type |
Not native in Doctrine, needs DB/platform config |
If you want to use ENUM:
@ORM\Column(type="string", columnDefinition="ENUM('active', 'inactive')")
|
Option |
Purpose |
Sample Usage |
|---|---|---|
|
type |
Data type for the column |
@ORM\Column(type="string") |
|
length |
Max length (used with |
@ORM\Column(type="string", length=100) |
|
precision |
Total digits for |
@ORM\Column(type="decimal", precision=10, scale=2) |
|
scale |
Digits after decimal point |
@ORM\Column(type="decimal", precision=10, scale=2) |
|
nullable |
Whether field can be NULL |
@ORM\Column(type="string", nullable=true) |
|
unique |
Enforce unique constraint |
@ORM\Column(type="string", unique=true) |
|
options |
Additional DB-level options (e.g., default) |
@ORM\Column(type="string", options={"default": "active"}) |
|
columnDefinition |
Raw SQL column definition |
@ORM\Column(type="string", columnDefinition="ENUM('a', 'b') NOT NULL") |
|
id |
Mark as primary key |
@ORM\Id |
|
generatedValue |
Auto-increment primary key |
@ORM\GeneratedValue(strategy="AUTO") |
|
name |
Custom column name |
@ORM\Column(name="user_email", type="string") |
|
Relation Type |
Description |
Sample Usage |
|---|---|---|
|
@OneToOne |
One-to-one relation |
@ORM\OneToOne(targetEntity="Profile") |
|
@ManyToOne |
Many-to-one (foreign key) |
@ORM\ManyToOne(targetEntity="Category") |
|
@OneToMany |
One-to-many (inverse side) |
@ORM\OneToMany(targetEntity="Order", mappedBy="user") |
|
@ManyToMany |
Many-to-many |
@ORM\ManyToMany(targetEntity="Tag") |
|
Option |
Purpose |
Sample |
|---|---|---|
|
@JoinColumn |
Defines the join/foreign key column |
@JoinColumn(name="category_id", referencedColumnName="id", nullable=false) |
|
name |
Column name in current table |
name="category_id" |
|
referencedColumnName |
Column in foreign table |
referencedColumnName="id" |
|
nullable |
Can be null |
nullable=false |
|
onDelete |
Cascade behavior |
onDelete="CASCADE" |