6. Now that Doctrine knows about your
database, you can have it create the
database for you:
● $ php app/console
doctrine:database:create
Or destroy the DB:
● $ php app/console
doctrine:database:drop force
8. Creating an Entity Class
● Create this class inside the Entity directory of
your AcmeStoreBundle:
9. Add Mapping Information
● Doctrine allows you to persist entire objects to
the database and fetch entire objects out of the
database.
10.
11. Doctrine Field Types Reference
● Strings
● string (used for shorter strings)
● text (used for larger strings)
● Numbers
● integer
● smallint
● bigint
● decimal
● float
● Dates and Times (use a DateTime object for these fields in PHP)
● date
● time
● datetime
● Other Types
● boolean
● object (serialized and stored in a CLOB field)
● array (serialized and stored in a CLOB field)
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-
mapping.html#doctrine-mapping-types
13. ● You can also generate all known entities (i.e. any PHP
class with Doctrine mapping information) of a bundle or
an entire namespace:
● $ php app/console
doctrine:generate:entities AcmeStoreBundle
● $ php app/console
doctrine:generate:entities Acme
28. Using Custom Repository Classes
● When using a custom repository class, you still
have access to the default finder methods such
as find() and findAll().
31. since each Product class can relate to exactly one
Category object
● Then, generate the setter(s) and getter(s)
●
● tell Doctrine to add the new category table, and
product.category_id column, and new foreign key:
49. Mapping Defaults
● defaults for a join column in a one-to-one/many-to-one
association is as follows:
● name: "<fieldname>_id"
● referencedColumnName: "id"