在Doctrine中如何配置命名策略2 [英] How to configure naming strategy in Doctrine 2

查看:159
本文介绍了在Doctrine中如何配置命名策略2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了章关于手册中的教义命名策略。不幸的是,我不明白我必须在哪里放置配置代码。

I read the chapter about Doctrine naming strategies in the manual. Unfortunately I don't understand where I have to put the configuration code.

为了获得一个下划线命名策略,我应该使用这个代码:

In order to get an underscore naming strategy I should use this code:

$namingStrategy = new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy(CASE_UPPER);
$configuration()->setNamingStrategy($namingStrategy);

我应该在哪里?

我在Symfony 2 - 我想这对于配置来说很重要。

I'm on Symfony 2 — I guess this matters when it comes to configuration.

推荐答案

config.yml

doctrine:
    # ...

    orm:
        # ...
        naming_strategy: doctrine.orm.naming_strategy.underscore

这篇关于在Doctrine中如何配置命名策略2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆