__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* Part of the Joomla Framework Database Package
*
* @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Database;
/**
* Joomla Framework Database Factory class
*
* @since 1.0
*/
class DatabaseFactory
{
/**
* Method to return a database driver based on the given options.
*
* There are three global options and then the rest are specific to the database driver. The 'database' option determines which database is to
* be used for the connection. The 'select' option determines whether the connector should automatically select the chosen database.
*
* @param string $name Name of the database driver you'd like to instantiate
* @param array $options Parameters to be passed to the database driver.
*
* @return DatabaseInterface
*
* @since 1.0
* @throws Exception\UnsupportedAdapterException if there is not a compatible database driver
*/
public function getDriver(string $name = 'mysqli', array $options = []): DatabaseInterface
{
// Sanitize the database connector options.
$options['driver'] = preg_replace('/[^A-Z0-9_\.-]/i', '', $name);
$options['database'] = $options['database'] ?? null;
$options['select'] = $options['select'] ?? true;
$options['factory'] = $options['factory'] ?? $this;
// Derive the class name from the driver.
$class = __NAMESPACE__ . '\\' . ucfirst(strtolower($options['driver'])) . '\\' . ucfirst(strtolower($options['driver'])) . 'Driver';
// If the class still doesn't exist we have nothing left to do but throw an exception. We did our best.
if (!class_exists($class))
{
throw new Exception\UnsupportedAdapterException(sprintf('Unable to load Database Driver: %s', $options['driver']));
}
return new $class($options);
}
/**
* Gets an exporter class object.
*
* @param string $name Name of the driver you want an exporter for.
* @param DatabaseInterface|null $db Optional database driver to inject into the query object.
*
* @return DatabaseExporter
*
* @since 1.0
* @throws Exception\UnsupportedAdapterException if there is not a compatible database exporter
*/
public function getExporter(string $name, ?DatabaseInterface $db = null): DatabaseExporter
{
// Derive the class name from the driver.
$class = __NAMESPACE__ . '\\' . ucfirst(strtolower($name)) . '\\' . ucfirst(strtolower($name)) . 'Exporter';
// Make sure we have an exporter class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new Exception\UnsupportedAdapterException('Database Exporter not found.');
}
/** @var $o DatabaseExporter */
$o = new $class;
if ($db)
{
$o->setDbo($db);
}
return $o;
}
/**
* Gets an importer class object.
*
* @param string $name Name of the driver you want an importer for.
* @param DatabaseInterface|null $db Optional database driver to inject into the query object.
*
* @return DatabaseImporter
*
* @since 1.0
* @throws Exception\UnsupportedAdapterException if there is not a compatible database importer
*/
public function getImporter(string $name, ?DatabaseInterface $db = null): DatabaseImporter
{
// Derive the class name from the driver.
$class = __NAMESPACE__ . '\\' . ucfirst(strtolower($name)) . '\\' . ucfirst(strtolower($name)) . 'Importer';
// Make sure we have an importer class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new Exception\UnsupportedAdapterException('Database importer not found.');
}
/** @var $o DatabaseImporter */
$o = new $class;
if ($db)
{
$o->setDbo($db);
}
return $o;
}
/**
* Get a new iterator on the current query.
*
* @param string $name Name of the driver you want an iterator for.
* @param StatementInterface $statement Statement holding the result set to be iterated.
* @param string|null $column An optional column to use as the iterator key.
* @param string $class The class of object that is returned.
*
* @return DatabaseIterator
*
* @since 2.0.0
*/
public function getIterator(
string $name,
StatementInterface $statement,
?string $column = null,
string $class = \stdClass::class
): DatabaseIterator
{
// Derive the class name from the driver.
$iteratorClass = __NAMESPACE__ . '\\' . ucfirst($name) . '\\' . ucfirst($name) . 'Iterator';
// Make sure we have an iterator class for this driver.
if (!class_exists($iteratorClass))
{
// We can work with the base iterator class so use that
$iteratorClass = DatabaseIterator::class;
}
// Return a new iterator
return new $iteratorClass($statement, $column, $class);
}
/**
* Get the current query object or a new Query object.
*
* @param string $name Name of the driver you want an query object for.
* @param DatabaseInterface|null $db Optional database driver to inject into the query object.
*
* @return QueryInterface
*
* @since 1.0
* @throws Exception\UnsupportedAdapterException if there is not a compatible database query object
*/
public function getQuery(string $name, ?DatabaseInterface $db = null): QueryInterface
{
// Derive the class name from the driver.
$class = __NAMESPACE__ . '\\' . ucfirst(strtolower($name)) . '\\' . ucfirst(strtolower($name)) . 'Query';
// Make sure we have a query class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new Exception\UnsupportedAdapterException('Database Query class not found');
}
return new $class($db);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Command | Folder | 0775 |
|
|
| Event | Folder | 0775 |
|
|
| Exception | Folder | 0775 |
|
|
| Monitor | Folder | 0775 |
|
|
| Mysql | Folder | 0775 |
|
|
| Mysqli | Folder | 0775 |
|
|
| Pdo | Folder | 0775 |
|
|
| Pgsql | Folder | 0775 |
|
|
| Query | Folder | 0775 |
|
|
| Service | Folder | 0775 |
|
|
| Sqlazure | Folder | 0775 |
|
|
| Sqlite | Folder | 0775 |
|
|
| Sqlsrv | Folder | 0775 |
|
|
| DatabaseAwareInterface.php | File | 568 B | 0664 |
|
| DatabaseAwareTrait.php | File | 1.15 KB | 0664 |
|
| DatabaseDriver.php | File | 44.2 KB | 0664 |
|
| DatabaseEvents.php | File | 1.06 KB | 0664 |
|
| DatabaseExporter.php | File | 5.88 KB | 0664 |
|
| DatabaseFactory.php | File | 5.77 KB | 0664 |
|
| DatabaseImporter.php | File | 7.61 KB | 0664 |
|
| DatabaseInterface.php | File | 15.81 KB | 0664 |
|
| DatabaseIterator.php | File | 4.78 KB | 0664 |
|
| DatabaseQuery.php | File | 59.4 KB | 0664 |
|
| FetchMode.php | File | 2.24 KB | 0664 |
|
| FetchOrientation.php | File | 1.58 KB | 0664 |
|
| ParameterType.php | File | 1.07 KB | 0664 |
|
| QueryInterface.php | File | 18.98 KB | 0664 |
|
| QueryMonitorInterface.php | File | 899 B | 0664 |
|
| StatementInterface.php | File | 4.4 KB | 0664 |
|
| UTF8MB4SupportInterface.php | File | 1015 B | 0664 |
|