source of /sprout/Helpers/Pdb.php<?php /* * Copyright (C) 2017 Karmabunny Pty Ltd. * * This file is a part of SproutCMS. * * SproutCMS is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Foundation, either * version 2 of the License, or (at your option) any later version. * * For more information, visit <http://getsproutcms.com>. */ namespace Sprout\Helpers; use karmabunny\pdb\Compat\StaticPdb; use karmabunny\pdb\PdbConfig; use Kohana; /** * Class for doing database queries via PDO (PDO Database => Pdb) */ class Pdb extends StaticPdb { protected static $prefix = 'sprout_'; /** @inheritdoc */ public static function getConfig(string $name = null): PdbConfig { $name = $name ?? 'default'; $config = Kohana::config('database.' . $name); $conf = $config['connection']; $conf['type'] = str_replace('mysqli', 'mysql', $conf['type']); $conf['character_set'] = $config['character_set']; $conf['prefix'] = $config['prefix'] ?? self::$prefix; $conf['hacks'] = $config['hacks'] ?? []; return new PdbConfig($conf); } }
|