qbbr / pgsql-doctrine-random-function
Doctrine ORM 的 PostgreSQL RANDOM() 函数
1.0.1
2016-03-12 11:10 UTC
Requires
- doctrine/orm: >=2.2.0
This package is auto-updated.
Last update: 2024-09-14 17:00:57 UTC
README
Doctrine ORM 的 PostgreSQL RANDOM() 函数
安装
步骤 1: 下载包
$ composer require qbbr/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();