user980311
user980311

Reputation: 31

Symfony 2 and Database structure with yml

I am getting familiar to Symfony-2 after having good experience with Symfony 1.4.

I was searching for a good tutorial of creating the database from a yml file (or several files), and could not find any.

Is it possible to define relations between tables and constrains in the yml file? The only documentation I found talks about metadata in the Entity file.

Upvotes: 3

Views: 3519

Answers (2)

gremo
gremo

Reputation: 48899

Be aware: some kind of constraints will not work properly: e.g. fixed in a column of type string is not translated as CHAR if you use MySQL PDO, but as VARCHAR. Also i found some undocumented constraints for YALM:

Unique index

MyCompany\MyApp\MyClass:
  type: entity
  table: myclass
  uniqueConstraints:
    UNIQ_NAME:
    columns: [column1, column2]

General index:

MyCompany\MyApp\MyClass:
  type: entity
  table: myclass
  indexes:
    IDX_NAME:
    columns: [column1, column2]

Upvotes: 4

Stefan Gehrig
Stefan Gehrig

Reputation: 83622

Please see the Doctrine manual... You can switch between PHP Annotations, XML and YAML for every example.

Upvotes: 1

Related Questions