Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JDatabaseFactory

Liste de tous les membres

Fonctions membres publiques

 getDriver ($name= 'mysqli', $options=array())
 getExporter ($name, JDatabaseDriver $db=null)
 getImporter ($name, JDatabaseDriver $db=null)
 getQuery ($name, JDatabaseDriver $db=null)

Fonctions membres publiques statiques

static getInstance ()
static setInstance (JDatabaseFactory $instance=null)

Attributs privés statiques

static $_instance = null

Description détaillée

Définition à la ligne 19 du fichier factory.php.


Documentation des fonctions membres

JDatabaseFactory::getDriver (   $name = 'mysqli',
  $options = array() 
)

Method to return a JDatabaseDriver instance 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.

Instances are unique to the given options and new objects are only created when a unique options array is passed into the method. This ensures that we don't end up with unnecessary database connection resources.

Paramètres:
string$nameName of the database driver you'd like to instantiate
array$optionsParameters to be passed to the database driver.
Renvoie:
JDatabaseDriver A database driver object.
Depuis:
12.1
Exceptions:
RuntimeException

Définition à la ligne 46 du fichier factory.php.

{
// Sanitize the database connector options.
$options['driver'] = preg_replace('/[^A-Z0-9_\.-]/i', '', $name);
$options['database'] = (isset($options['database'])) ? $options['database'] : null;
$options['select'] = (isset($options['select'])) ? $options['select'] : true;
// Derive the class name from the driver.
$class = 'JDatabaseDriver' . ucfirst(strtolower($options['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 RuntimeException(sprintf('Unable to load Database Driver: %s', $options['driver']));
}
// Create our new JDatabaseDriver connector based on the options given.
try
{
$instance = new $class($options);
}
catch (RuntimeException $e)
{
throw new RuntimeException(sprintf('Unable to connect to the Database: %s', $e->getMessage()));
}
return $instance;
}
JDatabaseFactory::getExporter (   $name,
JDatabaseDriver  $db = null 
)

Gets an exporter class object.

Paramètres:
string$nameName of the driver you want an exporter for.
JDatabaseDriver$dbOptional JDatabaseDriver instance
Renvoie:
JDatabaseExporter An exporter object.
Depuis:
12.1
Exceptions:
RuntimeException

Définition à la ligne 86 du fichier factory.php.

{
// Derive the class name from the driver.
$class = 'JDatabaseExporter' . ucfirst(strtolower($name));
// 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 RuntimeException('Database Exporter not found.');
}
$o = new $class;
if ($db instanceof JDatabaseDriver)
{
$o->setDbo($db);
}
return $o;
}
JDatabaseFactory::getImporter (   $name,
JDatabaseDriver  $db = null 
)

Gets an importer class object.

Paramètres:
string$nameName of the driver you want an importer for.
JDatabaseDriver$dbOptional JDatabaseDriver instance
Renvoie:
JDatabaseImporter An importer object.
Depuis:
12.1
Exceptions:
RuntimeException

Définition à la ligne 119 du fichier factory.php.

{
// Derive the class name from the driver.
$class = 'JDatabaseImporter' . ucfirst(strtolower($name));
// 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 RuntimeException('Database importer not found.');
}
$o = new $class;
if ($db instanceof JDatabaseDriver)
{
$o->setDbo($db);
}
return $o;
}
static JDatabaseFactory::getInstance ( )
static

Gets an instance of the factory object.

Renvoie:
JDatabaseFactory
Depuis:
12.1

Définition à la ligne 148 du fichier factory.php.

{
return self::$_instance ? self::$_instance : new JDatabaseFactory;
}
JDatabaseFactory::getQuery (   $name,
JDatabaseDriver  $db = null 
)

Get the current query object or a new JDatabaseQuery object.

Paramètres:
string$nameName of the driver you want an query object for.
JDatabaseDriver$dbOptional JDatabaseDriver instance
Renvoie:
JDatabaseQuery The current query object or a new object extending the JDatabaseQuery class.
Depuis:
12.1
Exceptions:
RuntimeException

Définition à la ligne 164 du fichier factory.php.

{
// Derive the class name from the driver.
$class = 'JDatabaseQuery' . ucfirst(strtolower($name));
// 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 RuntimeException('Database Query class not found');
}
return new $class($db);
}
static JDatabaseFactory::setInstance ( JDatabaseFactory  $instance = null)
static

Gets an instance of a factory object to return on subsequent calls of getInstance.

Paramètres:
JDatabaseFactory$instanceA JDatabaseFactory object.
Renvoie:
void
Depuis:
12.1

Définition à la ligne 188 du fichier factory.php.

{
self::$_instance = $instance;
}

Documentation des données membres

JDatabaseFactory::$_instance = null
staticprivate

Définition à la ligne 27 du fichier factory.php.


La documentation de cette classe a été générée à partir du fichier suivant :