- md5
- d7f1089b47997049d95265b8d44c1773
- sha1
- 651e83d797c12263b44613409cc24f304ec9ec4f
- sha256
- d5ee1f2b4d30696b382ffc09629d135b1ea9b2a591d56f55d4f6ed9f73dc1341
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
<?php
/**
* @package Joomla.Installation
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Installation\Helper;
defined('_JEXEC') or die;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\DatabaseInterface;
/**
* Joomla Installation Database Helper Class.
*
* @since 1.6
*/
abstract class DatabaseHelper
{
/**
* Method to get a database driver.
*
* @param string $driver The database driver to use.
* @param string $host The hostname to connect on.
* @param string $user The user name to connect with.
* @param string $password The password to use for connection authentication.
* @param string $database The database to use.
* @param string $prefix The table prefix to use.
* @param boolean $select True if the database should be selected.
*
* @return DatabaseInterface
*
* @since 1.6
*/
public static function getDbo($driver, $host, $user, $password, $database, $prefix, $select = true)
{
static $db;
if (!$db)
{
// Build the connection options array.
$options = [
'driver' => $driver,
'host' => $host,
'user' => $user,
'password' => $password,
'database' => $database,
'prefix' => $prefix,
'select' => $select,
];
// Enable utf8mb4 connections for mysql adapters
if (strtolower($driver) === 'mysqli')
{
$options['utf8mb4'] = true;
}
if (strtolower($driver) === 'mysql')
{
$options['charset'] = 'utf8mb4';
}
// Get a database object.
$db = DatabaseDriver::getInstance($options);
}
return $db;
}
}
The same content is in 3 releases, Joomla 4.0.0-alpha10 to 4.0.0-alpha12. See them all, or every version of this file.