denisok94/doctrine-dql-operator

--

0.0.4 2024-12-16 18:03 UTC

This package is auto-updated.

Last update: 2024-12-16 18:04:38 UTC


README

  • Add sql operator date, cast, to_char, date_trunc, date_part, extract, coalesce, JSONB_AG, JSONB_HGG, JSONB_EX, JSONB_IN in doctrine
  • Add sql types timestampt, timestamptz, money in doctrine

Installation

Run:

composer require --prefer-dist denisok94/doctrine-dql-operator
# or
php composer.phar require --prefer-dist denisok94/doctrine-dql-operatorr

or add to the require section of your composer.json file:

"denisok94/doctrine-dql-operator": "*"
composer update
# or
php composer.phar update

Use

# ~config/packages/doctrine.yaml
doctrine:
    dbal:
        types:
            timestampt: Denisok94\DoctrineDqlOperator\DBAL\Timestampt
            timestamptz: Denisok94\DoctrineDqlOperator\DBAL\Timestamptz
            money: Denisok94\DoctrineDqlOperator\DBAL\MoneyType
    orm:
        dql:
            datetime_functions:
                DATE: Denisok94\DoctrineDqlOperator\DQL\Date
                DATE_TRUNC: Denisok94\DoctrineDqlOperator\DQL\DateTrunc
                EXTRACT: Denisok94\DoctrineDqlOperator\DQL\Extract
                DATE_PART: Denisok94\DoctrineDqlOperator\DQL\DatePart
            numeric_functions:
                ISNULL: Denisok94\DoctrineDqlOperator\DQL\IsNullFunction
            string_functions:
                CAST: Denisok94\DoctrineDqlOperator\DQL\Cast
                DOUBLE_PRECISION: Denisok94\DoctrineDqlOperator\DQL\DoublePrecisionFunction
                TO_CHAR: Denisok94\DoctrineDqlOperator\DQL\ToChar
                TO_CHAR_S: Denisok94\DoctrineDqlOperator\DQL\ToCharS
                JSONB_AG: Denisok94\DoctrineDqlOperator\DQL\JsonbAtGreater
                JSONB_HGG: Denisok94\DoctrineDqlOperator\DQL\JsonbHashGreaterGreater
                JSONB_EX: Denisok94\DoctrineDqlOperator\DQL\JsonbExistence
                JSONB_IN: Denisok94\DoctrineDqlOperator\DQL\JsonbIndex
use Doctrine\ORM\Mapping as ORM;
use Denisok94\DoctrineDqlOperator\DBAL\Money;

class Entity
{
    /**
     * @ORM\Column(type="money")
     * @var Money|null
     */
    protected $budget;

    /**
     * @ORM\Column(type="timestampt")
     * @var \DateTime|null
     */
    protected $created_at;

    /**
     * @ORM\Column(type="timestamptz")
     * @var \DateTime|null
     */
    protected $updated_at;
}