aldaflux / pgsql-doctrine-random-function
Doctrine ORM 的 PostgreSQL RANDOM() 函数,基于 https://packagist.org.cn/packages/qbbr/pgsql-doctrine-random-function 的分支
dev-master
2024-08-16 16:53 UTC
Requires
- doctrine/orm: >=2.2.0
This package is auto-updated.
Last update: 2024-09-16 16:56:20 UTC
README
Doctrine ORM 的 PostgreSQL RANDOM() 函数
安装步骤
步骤 1: 下载软件包
$ composer require aldaflux/pgsql-doctrine-random-function
步骤 2: 配置
# app/config/config.yml doctrine: orm: # ... dql: numeric_functions: Random: Qbbr\PgsqlDoctrineRandomFunction\DQL\RandomFunction
使用方法
$em = $this->getDoctrine()->getManager(); $result = $em->createQueryBuilder() ->select('e') ->from('AppBundle:Entity', 'e') ->orderBy('RANDOM()') ->setMaxResults(10) ->getQuery() ->getResult();