JDatabase

Database connector class.

abstract deprecated
since

11.1

deprecated

13.3 (Platform) & 4.0 (CMS)

package

Joomla.Platform

Methods

getConnectors

Get a list of available database connectors. The list will only be populated with connectors that both the class exists and the static test method returns true. This gives us the ability to have a multitude of connector classes that are self-aware as to whether or not they are able to be used on a given system.

getConnectors() : array
static deprecated
since

11.1

deprecated

13.1 (Platform) & 4.0 (CMS)

Response

arrayAn array of available database connectors.

getErrorMsg

Gets the error message from the database connection.

getErrorMsg(boolean $escaped = false) : string
deprecated
deprecated

13.3 (Platform) & 4.0 (CMS)

since

11.1

Arguments

$escaped

booleanTrue to escape the message string for use in JavaScript.

Response

stringThe error message for the most recent query.

getErrorNum

Gets the error number from the database connection.

getErrorNum() : integer
deprecated
since

11.1

deprecated

13.3 (Platform) & 4.0 (CMS)

Response

integerThe error number for the most recent query.

getInstance

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 'driver' option defines which JDatabaseDriver class is used for the connection -- the default is 'mysqli'. 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.

getInstance(array $options = array()) : \JDatabaseDriver
static deprecated

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.

since

11.1

deprecated

13.1 (Platform) & 4.0 (CMS)

Arguments

$options

arrayParameters to be passed to the database driver.

Response

\JDatabaseDriverA database object.

query

Execute the SQL statement.

query() : mixed
deprecated
since

11.1

throws

\RuntimeException

deprecated

13.1 (Platform) & 4.0 (CMS)

Response

mixedA database cursor resource on success, boolean false on failure.

splitSql

Splits a string of multiple queries into an array of individual queries.

splitSql(string $query) : array
static deprecated
since

11.1

deprecated

13.1 (Platform) & 4.0 (CMS)

Arguments

$query

stringInput SQL string with which to split into individual queries.

Response

arrayThe queries from the input string separated into an array.

stderr

Return the most recent error message for the database connector.

stderr(boolean $showSQL = false) : string
deprecated
since

11.1

deprecated

13.3 (Platform) & 4.0 (CMS)

Arguments

$showSQL

booleanTrue to display the SQL statement sent to the database as well as the error.

Response

stringThe error message for the most recent query.

test

Test to see if the connector is available.

test() : boolean
static deprecated
since

11.1

deprecated

12.3 (Platform) & 4.0 (CMS) - Use JDatabaseDriver::isSupported() instead.

Response

booleanTrue on success, false otherwise.