PHPackages                             oro-flex/doctrine-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. oro-flex/doctrine-utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

oro-flex/doctrine-utils
=======================

`Oro Doctrine Utils Component` provides some useful classes meant to make using Doctrine components easier.

4.2.0(4y ago)07461MITPHPPHP ~7.4.14 || ~8.0.0

Since Jan 8Pushed 4y agoCompare

[ Source](https://github.com/oro-flex/doctrine-utils)[ Packagist](https://packagist.org/packages/oro-flex/doctrine-utils)[ Docs](https://github.com/oroinc/platform/tree/master/src/Oro/Component/DoctrineUtils)[ RSS](/packages/oro-flex-doctrine-utils/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (1)

Oro Doctrine Utils Component
============================

[](#oro-doctrine-utils-component)

`Oro Doctrine Utils Component` provides some useful classes meant to make using Doctrine components easier.

QueryHintResolver class
-----------------------

[](#queryhintresolver-class)

The [QueryHintResolver](./ORM/QueryHintResolver.php) can be used to make [Doctrine query hints](https://doctrine-orm.readthedocs.org/en/latest/reference/dql-doctrine-query-language.html#query-hints) more flexible.

Descriptions of the class methods are below:

- **addTreeWalker** - Maps a query hint to a tree walker.
- **addOutputWalker** - Maps a query hint to an output walker.
- **resolveHints** - Resolves query hints.
- **addHint** - Adds a hint to a query object.
- **addHints** - Adds hints to a query object.

SqlWalker and TranslatableSqlWalker Output SQL Walkers
------------------------------------------------------

[](#sqlwalker-and-translatablesqlwalker-output-sql-walkers)

[SqlWalker](./ORM/Walker/SqlWalker.php) and [TranslatableSqlWalker](./ORM/Walker/TranslatableSqlWalker.php) are [Doctrine output walkers](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/dql-custom-walkers.html#modify-the-output-walker-to-generate-vendor-specific-sql) used to modify queries to be more vendor-optimized. TranslatableSqlWalker should be used instead of the Gedmo TranslationWalker.

Both walkers utilize [DecoratedSqlWalkerTrait](./ORM/Walker/DecoratedSqlWalkerTrait.php) which is responsible for decoration of all SQL output walker calls with calls to [OutputAstWalkerInterface](./ORM/Walker/OutputAstWalkerInterface.php) before result building, and [OutputResultModifierInterface](./ORM/Walker/OutputResultModifierInterface.php) after the result is ready. OutputAstWalkerInterface and OutputResultModifierInterface are added to the query with two hints `HINT_AST_WALKERS` and `HINT_RESULT_MODIFIERS`. These hints are automatically filled with an array of classes during container building. To add your own AST walker or Output Result Modifier to the decoration, use the `oro_entity.sql_walker` DI tag.

OutputAstWalkerInterface should be used to modify AST tree, but not to generate SQL. To change the resulting SQL, use OutputResultModifierInterface (it has access to AST but should not modify it).

```
oro_entity.sql_walker.union:
    class: Oro\Component\DoctrineUtils\ORM\Walker\UnionOutputResultModifier
    public: false
    abstract: true
    tags:
        - { name: oro_entity.sql_walker }
```

Out-of-the-box, there are several Output Result modifiers registered:

### PostgreSqlOrderByNullsOutputResultModifier - NULLs Sorting

[](#postgresqlorderbynullsoutputresultmodifier---nulls-sorting)

One of the class goals is to align NULLs sorting logic for MySQL and PostgreSQL. By default when ASC sorting is performed NULLs are sorted first in MySQL and last in PostgreSQL. SqlWalker applies NULLS FIRST instruction for nullable columns when them appears in ORDER BY clause. For DESC sorting NULLS LAST instruction is applied as well.

This behavior may be turned off by setting special query hint `HINT_DISABLE_ORDER_BY_MODIFICATION_NULLS`

```
$query->setHint('HINT_DISABLE_ORDER_BY_MODIFICATION_NULLS', true);
```

### MySqlUseIndexOutputResultModifier - force to [use index](https://dev.mysql.com/doc/refman/5.7/en/index-hints.html) for MySQL

[](#mysqluseindexoutputresultmodifier---force-to-use-index-for-mysql)

MySqlUseIndexOutputResultModifier provides functionality of specifying concrete indexes that should be used by MySQL. Indexes are fetched from query hint `HINT_USE_INDEX`

```
$query->setHint('HINT_USE_INDEX', 'my_custom_idx');
```

### UnionOutputResultModifier - Union SELECT to a given query

[](#unionoutputresultmodifier---union-select-to-a-given-query)

UnionOutputResultModifier provides union functionality. Union is added to a placeholder which is saved under `HINT_UNION_KEY`. The value of UNION query is fetched from the `HINT_UNION_VALUE`

PreciseOrderByWalker class
--------------------------

[](#preciseorderbywalker-class)

The [PreciseOrderByWalker](./ORM/Walker/PreciseOrderByWalker.php) is an [Doctrine tree walker](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/dql-custom-walkers.html) that is used to modify ORDER BY clause of a query to make sure that records will be returned in the same order independent from a state of SQL server and from values of OFFSET and LIMIT clauses. This is achieved by adding the primary key column of the first root entity to the end of ORDER BY clause.

Example of usage:

```
$query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [PreciseOrderByWalker::class]);
```

TransactionWatcherInterface interface
-------------------------------------

[](#transactionwatcherinterface-interface)

Sometimes it is required to perform some work only after data are committed to the database. For instance, sending notifications to users or to external systems. In this case the [TransactionWatcherInterface](./DBAL/TransactionWatcherInterface.php)can be helpful.

To be able to register DBAL transaction watchers you need to register the [AddTransactionWatcherCompilerPass](.DependencyInjection/AddTransactionWatcherCompilerPass.php) compiler pass and class loader for the transaction watcher aware connection proxy in your application, for example:

```
class AppBundle extends Bundle
{
    public function __construct(KernelInterface $kernel)
    {
        TransactionWatcherConfigurator::registerConnectionProxies($kernel->getCacheDir());
    }

    public function build(ContainerBuilder $container)
    {
        $container->addCompilerPass(
            new AddTransactionWatcherCompilerPass('oro.doctrine.connection.transaction_watcher')
        );
    }
}
```

QueryBuilderUtil class
----------------------

[](#querybuilderutil-class)

Constructing DQL queries dynamically may make them vulnerable for injections. To be sure that data, passed ans field name or table alias is safe `QueryBuilderUtil` contains a set of methods: `sprintf` - should be as query safe replacement instead of sprintf `checkIdentifier` - when there is a need to safely pass variable into query as part of identifier `getField` - is a shortcut for QueryBuilderUtil::sprintf('%s.%s', $alias, $field)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1591d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/75abdcaa05b077ff39155d3e281bd1c52dcce0e94b30da0b8927d40ce2ff8c52?d=identicon)[inri13666](/maintainers/inri13666)

---

Top Contributors

[![vsoroka](https://avatars.githubusercontent.com/u/4763952?v=4)](https://github.com/vsoroka "vsoroka (23 commits)")[![x86demon](https://avatars.githubusercontent.com/u/196506?v=4)](https://github.com/x86demon "x86demon (19 commits)")[![mbessolov](https://avatars.githubusercontent.com/u/2725121?v=4)](https://github.com/mbessolov "mbessolov (8 commits)")[![nenadalm](https://avatars.githubusercontent.com/u/1227933?v=4)](https://github.com/nenadalm "nenadalm (7 commits)")[![anyt](https://avatars.githubusercontent.com/u/5183991?v=4)](https://github.com/anyt "anyt (5 commits)")[![webevt](https://avatars.githubusercontent.com/u/3187691?v=4)](https://github.com/webevt "webevt (4 commits)")[![alexandr-parkhomenko](https://avatars.githubusercontent.com/u/6198444?v=4)](https://github.com/alexandr-parkhomenko "alexandr-parkhomenko (3 commits)")[![dnahrebecki](https://avatars.githubusercontent.com/u/4091515?v=4)](https://github.com/dnahrebecki "dnahrebecki (3 commits)")[![SergeyZ](https://avatars.githubusercontent.com/u/92912310?v=4)](https://github.com/SergeyZ "SergeyZ (3 commits)")[![ishirko](https://avatars.githubusercontent.com/u/5603318?v=4)](https://github.com/ishirko "ishirko (2 commits)")[![oro-panasiukr](https://avatars.githubusercontent.com/u/39378223?v=4)](https://github.com/oro-panasiukr "oro-panasiukr (2 commits)")[![venimus](https://avatars.githubusercontent.com/u/632282?v=4)](https://github.com/venimus "venimus (2 commits)")[![vitaliyberdylo](https://avatars.githubusercontent.com/u/1668719?v=4)](https://github.com/vitaliyberdylo "vitaliyberdylo (2 commits)")[![EugeneC](https://avatars.githubusercontent.com/u/1182885?v=4)](https://github.com/EugeneC "EugeneC (2 commits)")[![dxops](https://avatars.githubusercontent.com/u/1804871?v=4)](https://github.com/dxops "dxops (1 commits)")[![dshatovskiy](https://avatars.githubusercontent.com/u/3697012?v=4)](https://github.com/dshatovskiy "dshatovskiy (1 commits)")[![vladimirseniuk](https://avatars.githubusercontent.com/u/3224886?v=4)](https://github.com/vladimirseniuk "vladimirseniuk (1 commits)")[![inri13666](https://avatars.githubusercontent.com/u/1381253?v=4)](https://github.com/inri13666 "inri13666 (1 commits)")[![mfejczaruk](https://avatars.githubusercontent.com/u/6344380?v=4)](https://github.com/mfejczaruk "mfejczaruk (1 commits)")[![pusachev](https://avatars.githubusercontent.com/u/17767002?v=4)](https://github.com/pusachev "pusachev (1 commits)")

### Embed Badge

![Health badge](/badges/oro-flex-doctrine-utils/health.svg)

```
[![Health](https://phpackages.com/badges/oro-flex-doctrine-utils/health.svg)](https://phpackages.com/packages/oro-flex-doctrine-utils)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
