davidkmenta/doctrine-simple-array-types
最新稳定版本:1.1.0
Composer 安装命令:
composer require davidkmenta/doctrine-simple-array-types
包简介
Extended simple array types for Doctrine
README 文档
README
A Doctrine field type for simple arrays of integers, floats and strings.
Description
These types mainly solve two common problems:
- simple_string_array solves the problem with strings containing a comma symbol. Such strings cannot be persisted in the simple_array type provided by the Doctrine.
- simple_integer_array and simple_float_array extends the simple_array type from the Doctrine. These types solve the problem when a persisted integer or float is returned from the database as a string.
Installation
Run the following command:
composer require davidkmenta/doctrine-simple-array-types
Examples
To configure Doctrine to use this set of types, you'll need to set up the following in your bootstrap:
<?php \Doctrine\DBAL\Types\Type::addType('simple_string_array', 'DavidKmenta\DoctrineSimpleArrayTypes\SimpleStringArrayType'); $entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('simple_string_array', 'simple_string_array'); \Doctrine\DBAL\Types\Type::addType('simple_integer_array', 'DavidKmenta\DoctrineSimpleArrayTypes\SimpleIntegerArrayType'); $entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('simple_integer_array', 'simple_integer_array'); \Doctrine\DBAL\Types\Type::addType('simple_float_array', 'DavidKmenta\DoctrineSimpleArrayTypes\SimpleFloatArrayType'); $entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('simple_float_array', 'simple_float_array');
Or, if you're using the Symfony, set types in your Doctrine configuration file (eg: doctrine.yml):
doctrine: dbal: types: simple_string_array: 'DavidKmenta\DoctrineSimpleArrayTypes\SimpleStringArrayType' simple_integer_array: 'DavidKmenta\DoctrineSimpleArrayTypes\SimpleIntegerArrayType' simple_float_array: 'DavidKmenta\DoctrineSimpleArrayTypes\SimpleFloatArrayType'
Then, in your entities, you may annotate properties by setting the @Column type to simple_string_array, simple_integer_array or simple_float_array.
统计信息
- 总下载量: 164.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-16