mysql 中的 DC2Type 数组数据类型是什么 [英] What is DC2Type array datatype in mysql

查看:31
本文介绍了mysql 中的 DC2Type 数组数据类型是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在使用 Symfony2 和 Doctic2,并且实现了一种称为 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:array 是字段的注释.

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屋!

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