Doctrine
Projects
ORM
DBAL
MongoDB ODM
Coding Standard
Collections
Common
Data fixtures
Event Manager
Inflector
Instantiator
Lexer
Migrations
PHPCR ODM
Persistence
RST Parser
View All
Development
Community
Contributor Workflow
Maintainer Workflow
Contribute to Website
Policies
GitHub
Styleguide
Sponsorship
Partners
Blog
Edit
Tutorials
Getting Started with Doctrine
Guide Assumptions
What is Doctrine?
What are Entities?
An Example Model: Bug Tracker
Project Setup
Obtaining the EntityManager
Generating the Database Schema
Starting with the Product Entity
Adding behavior to Entities
Adding Bug and User Entities
Implementing more Requirements
Queries for Application Use-Cases
List of Bugs
Array Hydration of the Bug List
Find by Primary Key
Dashboard of the User
Number of Bugs
Updating Entities
Entity Repositories
Conclusion
Getting Started: Database First
Getting Started: Model First
Working with Indexed Associations
Mapping Indexed Associations
Querying indexed associations
Outlook into the Future
Extra Lazy Associations
Enabling Extra-Lazy Associations
Composite and Foreign Keys as Primary Key
General Considerations
Primitive Types only
Identity through foreign Entities
Use-Case 1: Dynamic Attributes
Use-Case 2: Simple Derived Identity
Use-Case 3: Join-Table with Metadata
Performance Considerations
Ordering To-Many Associations
Override Field Association Mappings In Subclasses
Pagination
Separating Concerns using Embeddables
Initializing embeddables
Column Prefixing
DQL
Reference
Architecture
Using an Object-Relational Mapper
Requirements
Doctrine ORM Packages
Collection, Event Manager and Persistence
The DBAL Package
The ORM Package
Terminology
Entities
Mapped Superclasses
Transient Classes
Entity states
Persistent fields
Serializing entities
The EntityManager
Transactional write-behind
The Unit of Work
Installation and Configuration
Class loading
Obtaining an EntityManager
Setting up the Commandline Tool
Frequently Asked Questions
Database Schema
How do I set the charset and collation for MySQL tables?
Entity Classes
How can I add default values to a column?
Mapping
Why do I get exceptions about unique constraint failures during $em->flush()?
Associations
What is wrong when I get an InvalidArgumentException "A new entity was found through the relationship.."?
How can I filter an association?
I call clear() on a One-To-Many collection but the entities are not deleted
How can I add columns to a many-to-many table?
How can i paginate fetch-joined collections?
Why does pagination not work correctly with fetch joins?
Inheritance
Can I use Inheritance with Doctrine ORM?
Why does Doctrine not create proxy objects for my inheritance hierarchy?
EntityGenerator
Why does the EntityGenerator not do X?
Why does the EntityGenerator not generate inheritance correctly?
Performance
Why is an extra SQL query executed every time I fetch an entity with a one-to-one relation?
Doctrine Query Language
What is DQL?
Can I sort by a function (for example ORDER BY RAND()) in DQL?
Is it better to write DQL or to generate it with the query builder?
A Query fails, how can I debug it?
Basic Mapping
Creating Classes for the Database
Property Mapping
PHP Types Mapping
Property Hooks
Doctrine Mapping Types
Identifiers / Primary Keys
Identifier Generation Strategies
Sequence Generator
Composite Keys
Quoting Reserved Words
Association Mapping
Many-To-One, Unidirectional
One-To-One, Unidirectional
One-To-One, Bidirectional
One-To-One, Self-referencing
One-To-Many, Bidirectional
One-To-Many, Unidirectional with Join Table
One-To-Many, Self-referencing
Many-To-Many, Unidirectional
Many-To-Many, Bidirectional
Owning and Inverse Side on a ManyToMany Association
Many-To-Many, Self-referencing
Mapping Defaults
Collections
Initializing Collections
Inheritance Mapping
Mapped Superclasses
Entity Inheritance
Performance impact on to-one associations
Single Table Inheritance
Design-time considerations
Performance impact
SQL Schema considerations
Class Table Inheritance
Design-time considerations
Performance impact
SQL Schema considerations
Overrides
Association Override
Attribute Override
Query the Type
Working with Objects
Entities and the Identity Map
Entity Object Graph Traversal
Persisting entities
Removing entities
Join-table management when removing from many-to-many collections
Performance of different deletion strategies
Detaching entities
Synchronization with the Database
Effects of Database and UnitOfWork being Out-Of-Sync
Synchronizing New and Managed Entities
Synchronizing Removed Entities
The size of a Unit of Work
The cost of flushing
Direct access to a Unit of Work
Entity State
Querying
By Primary Key
By Simple Conditions
By Criteria
By Eager Loading
By Lazy Loading
By DQL
By Native Queries
Custom Repositories
Working with Associations
Association Example Entities
Establishing Associations
Removing Associations
Association Management Methods
Synchronizing Bidirectional Collections
Transitive persistence / Cascade Operations
Persistence by Reachability: Cascade Persist
Orphan Removal
Filtering Collections
Implementing a TypedFieldMapper
DefaultTypedFieldMapper
TypedFieldMapper interface
ChainTypedFieldMapper
Implementing a TypedFieldMapper
Events
The Event System
Registering Event Handlers
Events Overview
Naming convention
Lifecycle Callbacks
Lifecycle Callbacks Event Argument
Listening and subscribing to Lifecycle Events
Implementing Event Listeners
prePersist
preRemove
preFlush
onFlush
postFlush
preUpdate
postUpdate, postRemove, postPersist
postLoad
onClear
Entity listeners
Entity listeners class
Entity listeners resolver
Load ClassMetadata Event
SchemaTool Events
postGenerateSchemaTable
postGenerateSchema
Doctrine Internals explained
How Doctrine keeps track of Objects
How Doctrine Detects Changes
Query Internals
The different ORM Layers
Hydration
Persisters
UnitOfWork
ResultSetMapping
DQL Parser
SQLWalker
EntityManager
ClassMetadataFactory
Association Updates: Owning Side and Inverse Side
Bidirectional Associations
Important concepts
Transactions and Concurrency
Transaction Demarcation
Approach 1: Implicitly
Approach 2: Explicitly
Exception Handling
Locking Support
Optimistic Locking
Important Implementation Notes
Pessimistic Locking
Batch Processing
Bulk Inserts
Bulk Updates
DQL UPDATE
Iterating results
Bulk Deletes
DQL DELETE
Iterating results
Iterating Large Results for Data-Processing
Doctrine Query Language
Types of DQL queries
SELECT queries
DQL SELECT clause
Result format
Joins
Named and Positional Parameters
DQL SELECT Examples
Partial Hydration Syntax
"NEW" Operator Syntax
Using INDEX BY
UPDATE queries
DELETE queries
Comments in queries
Functions, Operators, Aggregates
DQL Functions
Arithmetic operators
Aggregate Functions
Other Expressions
Adding your own functions to the DQL language
Querying Inherited Classes
Single Table
Class Table Inheritance
The Query class
Query Result Formats (Hydration Modes)
getResult()
getArrayResult()
getScalarResult()
getSingleScalarResult()
getSingleColumnResult()
getSingleResult()
getOneOrNullResult()
Custom Hydration Modes
Pure and Mixed Results
Fetching Multiple FROM Entities
Iterating Large Result Sets
Functions
Parameters
Cache related API
Query Hints
Query Cache (DQL Query Only)
First and Max Result Items (DQL Query Only)
Temporarily change fetch mode in DQL
EBNF
Document syntax:
Terminals
Query Language
Statements
Identifiers
Path Expressions
Clauses
Items
From, Join and Index by
Select Expressions
Conditional Expressions
Collection Expressions
Literal Values
Input Parameter
Arithmetic Expressions
Scalar and Type Expressions
Aggregate Expressions
Case Expressions
Other Expressions
Functions
The QueryBuilder
Constructing a new QueryBuilder object
Working with QueryBuilder
High level API methods
Binding parameters to your query
Limiting the Result
Executing a Query
The Expr class
Adding a Criteria to a Query
Low Level API
Expr* classes
Binding Parameters to Placeholders
Native SQL
The NativeQuery class
ResultSetMappingBuilder
The ResultSetMapping
Entity results
Joined entity results
Field results
Scalar results
Special case: DTOs
Meta results
Discriminator Column
Examples
Change Tracking Policies
Deferred Implicit
Deferred Explicit
Partial Hydration
Partial Objects
What is the problem?
When should I force partial objects?
Attributes Reference
Index
Reference
#[AssociationOverride]
#[AttributeOverride]
#[Column]
#[Cache]
#[ChangeTrackingPolicy]
#[CustomIdGenerator]
#[DiscriminatorColumn]
#[DiscriminatorMap]
#[Embeddable]
#[Embedded]
#[Entity]
#[GeneratedValue]
#[HasLifecycleCallbacks]
#[Index]
#[Id]
#[InheritanceType]
#[JoinColumn], #[InverseJoinColumn]
#[JoinTable]
#[ManyToOne]
#[ManyToMany]
#[MappedSuperclass]
#[OneToOne]
#[OneToMany]
#[OrderBy]
#[PostLoad]
#[PostPersist]
#[PostRemove]
#[PostUpdate]
#[PrePersist]
#[PreRemove]
#[PreUpdate]
#[SequenceGenerator]
#[Table]
#[UniqueConstraint]
#[Version]
XML Mapping
Simplified XML Driver