/
jagepard
/
Rudra-Model
Обзор
Документация
Войти
/
jagepard
/
Rudra-Model
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Drivers/SQLite.php
70 строк
2 KB
Jagepard
Add DISTINCT to groupConcat (PG/SQLite untested)
29 июл 2026, 14:33
29 июл 2026, 14:33
759d29c
Код
Авторство
О чём код?
<?php declare(strict_types=1); /** * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * @author Korotkov Danila (Jagepard) <jagepard@yandex.ru> * @license https://mozilla.org/MPL/2.0/ MPL-2.0 */ namespace Rudra\Model\Drivers; use Rudra\Model\Interfaces\SqlDialectInterface; class SQLite implements SqlDialectInterface { #[\Override] public function groupConcat(string $fieldName, string $alias, ?string $orderBy, bool $distinct = true): string { $distinctStr = $distinct ? 'DISTINCT ' : ''; return ", GROUP_CONCAT({$distinctStr}$fieldName, ';') $alias"; } #[\Override] public function close(): string { return ")"; } #[\Override] public function integer(string $field, string $default = "", bool $autoincrement = false, string $null = "NOT NULL"): string { if ($autoincrement) { return "$field INTEGER PRIMARY KEY"; } return ", $field INTEGER $null $default"; } #[\Override] public function string(string $field, string $default = "", string $null = "NOT NULL"): string { return ", $field TEXT $null $default"; } #[\Override] public function text(string $field, string $null = "NOT NULL"): string { return ", $field TEXT $null"; } #[\Override] public function createdAt(): string { return ", created_at TEXT DEFAULT CURRENT_TIMESTAMP"; } #[\Override] public function updatedAt(): string { return ", updated_at TEXT DEFAULT CURRENT_TIMESTAMP"; } #[\Override] public function primaryKey(string $field): string { return ""; } }