什么是mysql中的DC2Type数组数据类型 [英] What is DC2Type array datatype in mysql
问题描述
我最近一直在使用Symfony2和doctrine2,并实现了一种称为DC2Type:array的特殊数据类型,某些Symfony2角色另存为该数据类型.对我来说,它就像一个序列化的PHP数组,其中a表示元素总数,i是数组索引.
I have been working with Symfony2 and doctrine2 recently and have realized a peculiar datatype called DC2Type:array that certain Symfony2 Roles get saved as. To me it just looks like a serialized PHP array where a signifies the total number of elements, i is the array index.
值看起来像这样:
a:15:{i:0;s:32:"ROLE_SONATA_USER_ADMIN_USER_EDIT";i:1;s:32:"ROLE_SONATA_USER_ADMIN_USER_LIST";i:2;s:34:"ROLE_SONATA_USER_ADMIN_USER_CREATE";i:3;s:32:"ROLE_SONATA_USER_ADMIN_USER_VIEW";i:4;s:34:"ROLE_SONATA_USER_ADMIN_USER_DELETE";i:5;s:36:"ROLE_SONATA_USER_ADMIN_USER_OPERATOR";i:6;s:34:"ROLE_SONATA_USER_ADMIN_USER_MASTER";i:7;s:33:"ROLE_SONATA_USER_ADMIN_GROUP_EDIT";i:8;s:33:"ROLE_SONATA_USER_ADMIN_GROUP_LIST";i:9;s:35:"ROLE_SONATA_USER_ADMIN_GROUP_CREATE";i:10;s:33:"ROLE_SONATA_USER_ADMIN_GROUP_VIEW";i:11;s:35:"ROLE_SONATA_USER_ADMIN_GROUP_DELETE";i:12;s:37:"ROLE_SONATA_USER_ADMIN_GROUP_OPERATOR";i:13;s:35:"ROLE_SONATA_USER_ADMIN_GROUP_MASTER";i:14;s:10:"ROLE_ADMIN";}
我想知道这个数据类型是什么?
I want to know what this datatype is?
以下标识符表示什么:
s:
我已经搜索了互联网,但没有任何有用的数据.
I have searched the internet but haven't got any useful data.
我也碰到了这个菜谱条目- http://readthedocs.org/docs/doctrine-orm/en/2.0.x/cookbook/mysql-enums.html ,但未弄清起源.
I also bumped upon this cookbook entry - http://readthedocs.org/docs/doctrine-orm/en/2.0.x/cookbook/mysql-enums.html but didn't figure out the origin.
推荐答案
这不是数据类型.您可能已经注意到,列类型为LONGTEXT. DC2Type:数组是该字段的注释.
This is not a data type. You might have noticed that the column type is LONGTEXT. DC2Type:array is a comment of the field.
Doctrine使用字段的注释作为列的元数据存储位置.由于Mysql不允许您存储数组,因此Doctrine使用DC2Type:array作为注释,以了解如何反序列化内容.
Doctrine uses the field's comment as column's metadata storage place. Since Mysql does not allow you to store an array, Doctrine use DC2Type:array as comment in order to know how to unserialize the content.
看看下面的链接.
https://github.com/doctrine/dbal/issues/1614
在您提到的链接中,您可以看到注释DC2Type:enumvisibility指示该字段的内容是一个标志,指示该记录是否可见.它根本不是新的数据类型.在数据库级别,应将其视为辅助策略.对于Doctrine,这是一种自定义数据类型.
From the link you mentioned, you can see that the comment DC2Type:enumvisibility indicates that the content of the field is a flag, indicating that the record is visible or not. It is not a new data type at all. It should be considered an helper strategy in the database level. For Doctrine, it's a custom data type.
这篇关于什么是mysql中的DC2Type数组数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!