morontt / doctrine-functions
Doctrine2的附加DQL函数
dev-master
2016-10-14 12:15 UTC
Requires
- php: >=5.3.0
- doctrine/orm: >=2.2.3
This package is auto-updated.
Last update: 2024-09-29 04:42:20 UTC
README
Doctrine2的附加DQL函数
数值函数
RAND()参考
日期时间函数
MONTH()参考
字符串函数
substr(string, from, count)参考
安装
只需将此包添加到您的composer.json
{
"require": {
"morontt/doctrine-functions": "dev-master"
}
}
集成
1) 仅 Doctrine
根据Doctrine 文档,您可以这样注册此包中的函数。
<?php $config = new \Doctrine\ORM\Configuration(); $config->addCustomNumericFunction('rand', 'Morontt\DQL\Numeric\Rand'); ?>
2) 使用 Symfony 2
在 symfony 2 中,您可以在 config.yml 文件中注册您的函数。
doctrine: orm: entity_managers: default: dql: numeric_functions: rand: Morontt\DQL\Numeric\Rand datetime_functions: month: Morontt\DQL\DateTime\Month string_functions: substr: Morontt\DQL\String\Substr