dukecity/doctrineextensions
Composer 安装命令:
composer require dukecity/doctrineextensions
包简介
A set of extensions to Doctrine 2 that add support for additional query functions available in MySQL, Oracle, PostgreSQL and SQLite.
README 文档
README
A set of extensions to Doctrine 2 that add support for functions available in MySQL, Oracle, PostgreSQL and SQLite.
| DB | Functions |
|---|---|
| MySQL | ACOS, ADDTIME, AES_DECRYPT, AES_ENCRYPT, ANY_VALUE, ASCII, ASIN, ATAN, ATAN2, BIN_TO_UUID, BINARY, BIT_COUNT, BIT_XOR, CAST, CEIL, CHAR_LENGTH, COLLATE, CONCAT_WS, CONV, CONVERT_TZ, COS, COT, COUNTIF, CRC32, DATE, DATE_FORMAT, DATEADD, DATEDIFF, DATESUB, DAY, DAYNAME, DAYOFWEEK, DAYOFYEAR, DEGREES, DIV, EXP, EXTRACT, FIELD, FIND_IN_SET, FLOOR, FORMAT, FROM_BASE64, FROM_UNIXTIME, GREATEST, GROUP_CONCAT, HEX, HOUR, IFELSE, IFNULL, INET_ATON, INET_NTOA, INET6_ATON, INET6_NTOA, INSTR, IS_IPV4, IS_IPV4_COMPAT, IS_IPV4_MAPPED, IS_IPV6, JSON_CONTAINS, JSON_DEPTH, JSON_EXTRACT, JSON_LENGTH, JSON_UNQUOTE, LAG, LAST_DAY, LAST_INSERT_ID, LEAD, LEAST, LOG, LOG10, LOG2, LPAD, MAKEDATE, MATCH, MD5, MINUTE, MOD, MONTH, MONTHNAME, NOW, NULLIF, OVER, PERIOD_DIFF, PI, POINT, POWER, QUARTER, RADIANS, RAND, REGEXP, REGEXP_REPLACE, REGEXP_SUBSTR, REPLACE, ROUND, RPAD, SECOND, SECTOTIME, SHA1, SHA2, SIN, SOUNDEX, STD, STDDEV, STRTODATE, ST_DISTANCE_SPHERE, STR_TO_DATE, SUBSTRING_INDEX, TAN, TIME, TIMEDIFF, TIMESTAMPADD, TIMESTAMPDIFF, TIMETOSEC, TRUNCATE, UNHEX, UNIX_TIMESTAMP, UTC_TIMESTAMP, UUID_SHORT, UUID_TO_BIN, VARIANCE, WEEK, WEEKDAY, WEEKOFYEAR, YEAR, YEARMONTH, YEARWEEK |
| Oracle | CEIL, DAY, FLOOR, HOUR, LISTAGG, MINUTE, MONTH, NVL, SECOND, TO_CHAR, TO_DATE, TRUNC, YEAR |
| SQLite | CASE WHEN THEN ELSE END, DATE, DATE_FORMAT*, DAY, HOUR, IFNULL, JULIANDAY, MINUTE, MONTH, REPLACE, ROUND, SECOND, STRFTIME, WEEK, WEEKDAY, YEAR |
| PostgreSQL | AGE, AT_TIME_ZONE, COUNT_FILTER, DATE, DATE_PART, DATE_TRUNC, DAY, EXTRACT, GREATEST, HOUR, ILIKE, LEAST, MINUTE, MONTH, QUARTER, REGEXP_REPLACE, SECOND, STRING_AGG, TO_CHAR, TO_DATE, YEAR |
Note: SQLite date functions are implemented as
strftime(format, value). SQLite only supports the most common formats, sodate_formatwill convert the mysql substitutions to the closest available SQLite substitutions. This meansdate_format(field, '%b %D %Y') -> Jan 1st 2023becomesstrftime('%m %d %Y', field) -> 01 01 2023.
Installation
To install this library, run the command below and you will get the latest version:
composer require dukecity/doctrineextensions
Usage
If you are using DoctrineExtensions with Symfony read How to Register custom DQL Functions.
You can find example Symfony configuration for using DoctrineExtensions custom DQL functions in config.
If you are using DoctrineExtensions standalone, you might want to fire up the autoloader:
<?php $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', '/path/to/extensions'); $classLoader->register();
For more information check out the documentation of Doctrine DQL User Defined Functions.
Motivation
The original repo is not so good maintained anymore. The motivation for this Repo, is to
- add more functions
- improve CodeCoverage and testing (your help is welcome)
- modernize
Credits
Credits and thanks to the original repo and their maintainers. https://github.com/beberlei/DoctrineExtensions
Test and Contributing
If you want to run phpunit:
composer run test
If you want to run php-cs-fixer:
composer run lint
Notes
- MySQL
DATE_ADDis available in DQL asDATEADD(CURRENT_DATE(), 1, 'DAY') - MySQL
DATE_SUBis available in DQL asDATESUB(CURRENT_DATE(), 1, 'DAY') - MySQL
IFis available in DQL asIFELSE(field > 0, 'true', 'false')
Troubleshooting
Issues are disabled on this repository, if a custom DQL function that you want isn't provided, or does not support the arguments you want to pass, pull requests are open and we would love to have your contributions.
dukecity/doctrineextensions 适用场景与选型建议
dukecity/doctrineextensions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34.19k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2023 年 06 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「orm」 「doctrine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dukecity/doctrineextensions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dukecity/doctrineextensions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dukecity/doctrineextensions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Kinikit - PHP Application development framework MVC component
Store your language lines in the database, yaml or other sources
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
统计信息
- 总下载量: 34.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2023-06-16