. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use Illuminate\Database\Capsule\Manager; use Illuminate\Database\Query\Builder; /** * Database abstraction */ class DB extends Manager { /** * @internal */ public static function caseInsensitiveLikeOperator(): string { if (DB::connection()->getDriverName() === 'pgsql') { return 'ILIKE'; } if (DB::connection()->getDriverName() === 'sqlsrv') { return 'COLLATE SQL_UTF8_General_CI_AI LIKE'; } return 'LIKE'; } /** * @internal */ public static function groupConcat(string $column): string { switch (DB::connection()->getDriverName()) { case 'pgsql': case 'sqlsrv': return 'STRING_AGG(' . $column . ", ',')"; case 'mysql': case 'sqlite': default: return 'GROUP_CONCAT(' . $column . ')'; } } /** * PHPSTAN can't detect the magic methods in the parent class. */ public static function query(): Builder { return self::connection()->query(); } }