douci2015 2016-09-22 11:35
浏览 29

zend表达+主义自定义类型

I'm trying to map a custom type to a string. Here's my entity definition:

/**
 * @var string
 * 
 * @ORM\Column(name="type", type="string", columnDefinition="my_type_enum", nullable=false)
 */

But when I try to create migration (migration:diff) this is the output

[Doctrine\DBAL\DBALException] Unknown database type my_type_enum requested, Doctrine\DBAL\Platforms\PostgreSQL92Platform may not suppo rt it.

Seems I need to map my custom type my_type_enum to a string using mapping_types, but where in Zend Expressive? It's seems my configuration is ignored

...
     'doctrine' => [
       'dbal' => [
         'mapping_types' => [
           'my_type_enum' => 'string'
         ]
       ]
     ]
...
  • 写回答

2条回答 默认 最新

  • duannao8450 2016-09-23 06:53
    关注

    zend-expressive itself doesn't have doctrine support build in. It depends on the doctrine module and its factory that you are using. The factory starts the doctrine service with the config. So I would look inside the doctrine factory to figure out how and if it supports custom mapping types.

    In case yours doesn't support it, you can use container-interop-doctrine. It has support for this built in it seems (haven't tried it myself):

    <?php
    return [
        'doctrine' => [
            // ...
            'connection' => [
                'orm_default' => [
                    'driver_class' => \Doctrine\DBAL\Driver\PDOMySql\Driver::class,
                    'wrapper_class' => null,
                    'pdo' => null,
                    'configuration' => 'orm_default', 
                    'event_manager' => 'orm_default', 
                    'params' => [],
                    'doctrine_mapping_types' => [], // <-----
                    'doctrine_commented_types' => [],
                ],
            ],
            'types' = [
                'typename' => Type::class,
            ], // <-----
        ],
    ];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。