开发者

Symfony 2 and Database structure with yml

开发者 https://www.devze.com 2023-04-11 10:58 出处:网络
I am getting fami开发者_开发知识库liar to Symfony-2 after having good experience with Symfony 1.4.

I am getting fami开发者_开发知识库liar 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.


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]


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号