dukecity / doctrineextensions
一组扩展 Doctrine 2 的插件,增加了对 MySQL、Oracle、PostgreSQL 和 SQLite 中可用的附加查询函数的支持。
Requires
- php: ^8.1
- doctrine/orm: ^2.9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.38
- nesbot/carbon: ^2.71
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.4
- symfony/cache: ^6.3 || ^7.0
- symfony/yaml: ^6.3 || ^7.0
- dev-master
- 2.x-dev
- v2.0.2
- v2.0.1
- v2.0
- v1.3.0
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.3.0
- v0.2-alpha
- v0.1
- dev-feature/add-BIN_TO_UUID-for-mysql
- dev-feature/Allow_expression_in_DatePart
- dev-feature/allow_stringaggr_to_accept_sub_function
- dev-feature/add-flags-for-regex-replace-postgres
This package is auto-updated.
Last update: 2024-09-20 17:48:00 UTC
README
一组扩展 Doctrine 2 的插件,增加了对 MySQL、Oracle、PostgreSQL 和 SQLite 中可用的函数的支持。
注意:SQLite 日期函数实现为
strftime(format, value)
。SQLite 只支持最常用的格式,因此date_format
将将 mysql 替换转换为最接近的 SQLite 替换。这意味着date_format(field, '%b %D %Y') -> Jan 1st 2023
变为strftime('%m %d %Y', field) -> 01 01 2023
。
安装
要安装此库,请运行以下命令,您将获得最新版本
composer require dukecity/doctrineextensions
用法
如果您使用 DoctrineExtensions 与 Symfony,请阅读如何注册自定义 DQL 函数。
您可以在 此处 找到使用 DoctrineExtensions 自定义 DQL 函数的示例 Symfony 配置。
如果您单独使用 DoctrineExtensions,您可能需要启动自动加载器
<?php $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', '/path/to/extensions'); $classLoader->register();
有关更多信息,请参阅 Doctrine DQL 用户定义函数 的文档。
动机
原始存储库 original repo 已经 不再得到良好的维护。此存储库的动机是
- 添加更多功能
- 提高 CodeCoverage 和测试(欢迎您的帮助)
- 现代化
鸣谢
鸣谢原始存储库及其维护者。 https://github.com/beberlei/DoctrineExtensions
测试和贡献
如果您想运行 phpunit
composer run test
如果您想运行 php-cs-fixer
composer run lint
注意
- MySQL
DATE_ADD
在 DQL 中可用为DATEADD(CURRENT_DATE(), 1, 'DAY')
- MySQL
DATE_SUB
在 DQL 中可用为DATESUB(CURRENT_DATE(), 1, 'DAY')
- MySQL
IF
在 DQL 中可用为IFELSE(field > 0, 'true', 'false')
故障排除
此存储库已禁用问题,如果您想使用的自定义 DQL 函数未提供,或不受您想传递的参数支持,请发起拉取请求,我们非常愿意接受您的贡献。