avkluchko/postgres-doctrine-extensions

Doctrine extensions for working with PostgreSQL database

Installs: 339

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/avkluchko/postgres-doctrine-extensions

v1.0.0 2019-10-06 14:35 UTC

This package is auto-updated.

Last update: 2025-09-29 02:57:59 UTC


README

Build Status Total Downloads Latest Stable Version License

Doctrine extensions for working with PostgreSQL database

Requirements

Installation

composer require avkluchko/postgres-doctrine-extensions

Add the necessary extensions in the doctrine.yaml:

doctrine:
    orm:
        dql:
            string_functions:
                cast: AVKluchko\PostgresDoctrineExtensions\DQL\Cast
                date_part: AVKluchko\PostgresDoctrineExtensions\DQL\DatePart
                make_date: AVKluchko\PostgresDoctrineExtensions\DQL\MakeDate
                to_char: AVKluchko\PostgresDoctrineExtensions\DQL\ToChar

Usage

// src/Filters/SomeFilter.php
public class SomeFilter
{
    // ...
    protected function createCondition(string $year, string $field, string $operator, string $parameterName): string
    {
        return sprintf(
            'make_date(%s, cast(date_part(\'month\', %s) as integer), cast(date_part(\'day\', %s) as integer)) %s :%s',
            $year,
            $field,
            $field,
            $operator,
            $parameterName
        );
    }
}