elshafey/doctrine-window-functions

此包的最新版本(0.0.2)没有可用的许可证信息。

PHP Doctrine 扩展,添加窗口函数功能

0.0.2 2020-09-19 01:05 UTC

This package is not auto-updated.

Last update: 2024-09-15 19:36:13 UTC


README

窗口函数扩展是一个扩展,它使您能够在 doctrine 中轻松使用 SQL 窗口函数。

安装

composer require elshafey/doctrine-window-functions

如何使用

// configure the extension first
$entityManager->getConfiguration()->addCustomStringFunction(
    'WINDOW',
    \Elshafey\DoctrineExtensions\WindowFunctions\Query\Mysql\Window::class
);

// use your window function formula
$q=$entityManager->createQueryBuilder()
->select('p')
->addSelect('WINDOW(ROW_NUMBER()) OVER(PARTITION BY p.name) as rowNumber')
->from('\Entities\Product','p')->getQuery();

重要提示

在使用此扩展时请小心,不要忘记用 WINDOW() 包裹您的 窗口函数。示例

  • WINDOW(COUNT(*)) OVER(PARTITION BY e.columnNamw)
  • WINDOW(ROW_NUMBER()) OVER(PARTITION BY e.columnNamw)

扩展兼容性

目前,此扩展已在 MYSQL8 上进行测试并运行良好。其他平台,如 Oracle 或 MS-SQL Server,尚未测试。

缺失的功能

该扩展目前尚不支持 [frame_clause]

待办事项

添加 [frame_clause] 的功能