class JDatabaseFactory

Joomla Platform Database Factory class

Methods

getDriver( string $name = 'mysqli', array $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.

getExporter( string $name, JDatabaseDriver $db = null)

Gets an exporter class object.

getImporter( string $name, JDatabaseDriver $db = null)

Gets an importer class object.

static  JDatabaseFactory
getInstance()

Gets an instance of the factory object.

getQuery( string $name, JDatabaseDriver $db = null)

Get the current query object or a new JDatabaseQuery object.

static  void
setInstance( JDatabaseFactory $instance = null)

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

Details

JDatabaseDriver getDriver( string $name = 'mysqli', array $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.

Parameters

string $name Name of the database driver you'd like to instantiate
array $options Parameters to be passed to the database driver.

Return Value

JDatabaseDriver A database driver object.

Exceptions

RuntimeException

JDatabaseExporter getExporter( string $name, JDatabaseDriver $db = null)

Gets an exporter class object.

Parameters

string $name Name of the driver you want an exporter for.
JDatabaseDriver $db Optional JDatabaseDriver instance

Return Value

JDatabaseExporter An exporter object.

Exceptions

RuntimeException

JDatabaseImporter getImporter( string $name, JDatabaseDriver $db = null)

Gets an importer class object.

Parameters

string $name Name of the driver you want an importer for.
JDatabaseDriver $db Optional JDatabaseDriver instance

Return Value

JDatabaseImporter An importer object.

Exceptions

RuntimeException

static JDatabaseFactory getInstance()

Gets an instance of the factory object.

Return Value

JDatabaseFactory

JDatabaseQuery getQuery( string $name, JDatabaseDriver $db = null)

Get the current query object or a new JDatabaseQuery object.

Parameters

string $name Name of the driver you want an query object for.
JDatabaseDriver $db Optional JDatabaseDriver instance

Return Value

JDatabaseQuery The current query object or a new object extending the JDatabaseQuery class.

Exceptions

RuntimeException

static void setInstance( JDatabaseFactory $instance = null)

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

Parameters

JDatabaseFactory $instance A JDatabaseFactory object.

Return Value

void