elshafey/doctrine-window-functions

There is no license information available for the latest version (0.0.2) of this package.

PHP Doctrine Extension that add window functions functionality

0.0.2 2020-09-19 01:05 UTC

This package is not auto-updated.

Last update: 2025-08-03 23:39:23 UTC


README

Window functions extension is an extension that enable you to use SQL window functions easily inside doctrine.

Installation

composer require elshafey/doctrine-window-functions

How To Use

// 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();

Important Hint

Take care while using this extension and don't miss to wrap your window function by WINDOW(). Examples:

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

Extension Compatibility

Currently this extension is tested and works fine with MYSQL8. Other platforms like Oracle, or MS-SQL Server is not tested.

Missed Functionalities

The extension doesn't support yet [frame_clause]

TODO

Add the capability of [frame_clause]