Doctrine custom data type

牧云@^-^@ 提交于 2019-12-04 03:13:28

Another solution would be to register your Custom Type in the config file

You just need to add that in your config file:

# app/config/config.yml
doctrine:
    dbal:
        types:
            money:  My\Project\Types\MoneyType

You can find more info on how to register a custom mapping type in this Symfony Cookbook entry

Reza S

According to the link in previous answer you can just add it to src/My/Project/MyProjectBundle.php

use My\Project\Types\MoneyType;

class MyProject extends Bundle
{
    public function boot()
    {
        $em = $this->container->get('doctrine.orm.entity_manager');
        Type::addType('money', MoneyType::class);
        $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney','money');
    }
}

after reading this example implementation of the blob datatype, I think this should go into your boostrap file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!