Doctrine custom data type(教义自定义数据类型)
问题描述
我正在使用 Symfony2 开发应用程序.Symfony2 将 Doctrine 2 用于 DBAL 和 ORM.据我所知,Doctrine2 不支持 BLOB 数据类型.但是我想通过自定义数据类型映射来实现 BLOB 支持:
I'm developing application with Symfony2. Symfony2 is using Doctrine 2 for DBAL and ORM. As far as I know Doctrine2 doesn't have suport for BLOB data type. However I want to implement BLOB support through the custom data type mapping:
http://www.doctrine-project.org/docs/dbal/2.0/en/reference/types.html
但是我很难理解这部分应该去哪里.
However I'm struggling to understand where should this part go.
<?php
Type::addType('money', 'MyProjectTypesMoneyType');
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'money');
有人经历过吗?
我需要 BLOB 类型的原因是我想从现有的 MySQL 数据库中导入映射.
The reason I need a BLOB type is that I want to import mapping from existing MySQL database.
推荐答案
另一种解决方案是在配置文件中注册您的自定义类型
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: MyProjectTypesMoneyType
您可以在此 Symfony 中找到有关如何注册自定义映射类型的更多信息食谱条目
这篇关于教义自定义数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:教义自定义数据类型
基础教程推荐
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
