regnartson / doctrineextensions
Doctrine 2 的一组扩展,增加了对 MySQL、MsSQL 和 Oracle 中可用的一些额外查询函数的支持。
v1.2.4
2019-10-15 13:02 UTC
Requires
- php: ^7.1
- doctrine/orm: ^2.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- nesbot/carbon: *
- phpunit/phpunit: ^7.0 || ^8.0
- symfony/yaml: ^4.2
- zf1/zend-date: ^1.12
- zf1/zend-registry: ^1.12
- dev-master
- 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
This package is auto-updated.
Last update: 2024-09-16 22:17:33 UTC
README
Doctrine 2 的一组扩展,增加了对 MsSQL、MySQL、Oracle、PostgreSQL 和 SQLite 中可用函数的支持。
注意:Sqlite 日期函数实现为
strftime(format, value)
。Sqlite 只支持最常见的格式,所以date_format
将将 mysql 替换转换为最接近的 sqlite 替换。这意味着date_format(field, '%b %D %Y') -> Jan 1st 2015
变为strftime('%m %d %Y', field) -> 01 01 2015
。
安装
要安装此库,运行以下命令并将获取最新版本
composer require regnartson/doctrineextensions
如果你要运行 phpunit
make test
如果你要运行 php-cs-fixer
make fix # (or make lint for a dry-run)
使用方法
如果你在使用 DoctrineExtensions 与 Symfony,请阅读如何注册自定义 DQL 函数。
你可以在这里找到使用 DoctrineExtensions 自定义 DQL 函数的示例 Symfony 配置。
如果你独立使用 DoctrineExtensions,你可能需要启动自动加载器
<?php $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', '/path/to/extensions'); $classLoader->register();
更多信息请参阅Doctrine DQL 用户定义函数的文档。
备注
- 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')