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.
static array
getConnectors
()
Redefinition of:
- JDatabase::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.
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.
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.
-
array
$options: Parameters to be passed to the database driver.
Redefinition of:
- JDatabase::getInstance()
- Method to return a JDatabaseDriver instance based on the given options. There are three global options and then
Splits a string of multiple queries into an array of individual queries.
static array
splitSql
(string $sql)
-
string
$sql: Input SQL string with which to split into individual queries.
Redefinition of:
- JDatabase::splitSql()
- Splits a string of multiple queries into an array of individual queries.
Constructor.
JDatabaseDriver
__construct
(array $options)
-
array
$options: List of options used to configure the connection
Redefined in descendants as:
Adds a function callable just before disconnecting the database. Parameter of the callable is $this JDatabaseDriver
void
addDisconnectHandler
(callable $callable)
-
callable
$callable: Function to call in disconnect() method just before disconnecting from database
Alter database's character set, obtaining query string from protected member.
string
alterDbCharacterSet
(string $dbName)
-
string
$dbName: The database name that will be altered
Connects to the database if needed.
void
connect
()
Redefined in descendants as:
Determines if the connection to the server is active.
boolean
connected
()
Redefined in descendants as:
Create a new database using information from $options object, obtaining query string from protected member.
string
createDatabase
(stdClass $options, [boolean $utf = true])
-
stdClass
$options: Object used to pass user and database name to database driver. This object must have "db_name" and "db_user" set.
-
boolean
$utf: True if the database supports the UTF-8 character set.
Disconnects the database.
void
disconnect
()
Redefined in descendants as:
Drops a table from the database.
-
string
$table: The name of the database table to drop.
-
boolean
$ifExists: Optionally specify that the table must exist before it is dropped.
Redefined in descendants as:
Escapes a string for usage in an SQL statement.
string
escape
(string $text, [boolean $extra = false])
-
string
$text: The string to be escaped.
-
boolean
$extra: Optional parameter to provide extra escaping.
Redefined in descendants as:
Execute the SQL statement.
mixed
execute
()
Redefined in descendants as:
Method to fetch a row from the result set cursor as an array.
mixed
fetchArray
([mixed $cursor = null])
-
mixed
$cursor: The optional result set cursor from which to fetch the row.
Redefined in descendants as:
Method to fetch a row from the result set cursor as an associative array.
mixed
fetchAssoc
([mixed $cursor = null])
-
mixed
$cursor: The optional result set cursor from which to fetch the row.
Redefined in descendants as:
Method to fetch a row from the result set cursor as an object.
mixed
fetchObject
([mixed $cursor = null], [string $class = 'stdClass'])
-
mixed
$cursor: The optional result set cursor from which to fetch the row.
-
string
$class: The class name to use for the returned row object.
Redefined in descendants as:
Method to free up the memory used for the result set.
void
freeResult
([mixed $cursor = null])
-
mixed
$cursor: The optional result set cursor from which to fetch the row.
Redefined in descendants as:
Get the number of affected rows for the previous executed SQL statement.
integer
getAffectedRows
()
Redefined in descendants as:
Return the query string to alter the database character set.
string
getAlterDbCharacterSet
(string $dbName)
-
string
$dbName: The database name
Redefined in descendants as:
Get the database driver SQL statement log.
array
getCallStacks
()
Method to get the database collation in use by sampling a text field of a table in the database.
mixed
getCollation
()
Redefined in descendants as:
Method that provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods.
resource
getConnection
()
Get the total number of SQL statements executed by the database driver.
integer
getCount
()
Return the query string to create new Database.
Each database driver, other than MySQL, need to override this member to return correct string.
string
getCreateDatabaseQuery
(stdClass $options, boolean $utf)
-
stdClass
$options: Object used to pass user and database name to database driver. This object must have "db_name" and "db_user" set.
-
boolean
$utf: True if the database supports the UTF-8 character set.
Gets the name of the database used by this conneciton.
string
getDatabase
()
Returns a PHP date() function compliant date format for the database driver.
string
getDateFormat
()
Redefined in descendants as:
Gets an exporter class object.
Gets an importer class object.
Get a new iterator on the current query.
JDatabaseIterator
getIterator
([
string $column =
null], [
string $class =
'stdClass'])
-
string
$column: An option column to use as the iterator key.
-
string
$class: The class of object that is returned.
Get the database driver SQL statement log.
array
getLog
()
Get the minimum supported database version.
string
getMinimum
()
Get the null or zero representation of a timestamp for the database driver.
string
getNullDate
()
Get the number of returned rows for the previous executed SQL statement.
integer
getNumRows
([resource $cursor = null])
-
resource
$cursor: An optional database cursor resource to extract the row count from.
Redefined in descendants as:
Get the common table prefix for the database driver.
string
getPrefix
()
Get the current query object or a new JDatabaseQuery object.
-
boolean
$new: False to return the current query object, True to return a new JDatabaseQuery object.
Redefined in descendants as:
Retrieves field information about the given tables.
array
getTableColumns
(string $table, [boolean $typeOnly = true])
-
string
$table: The name of the database table.
-
boolean
$typeOnly: True (default) to only return field types.
Redefined in descendants as:
Shows the table CREATE statement that creates the given tables.
array
getTableCreate
(mixed $tables)
-
mixed
$tables: A table name or a list of table names.
Redefined in descendants as:
Retrieves field information about the given tables.
array
getTableKeys
(mixed $tables)
-
mixed
$tables: A table name or a list of table names.
Redefined in descendants as:
Method to get an array of all tables in the database.
array
getTableList
()
Redefined in descendants as:
Get the database driver SQL statement log.
array
getTimings
()
Determine whether or not the database engine supports UTF-8 character encoding.
boolean
getUTFSupport
()
Get the version of the database connector
string
getVersion
()
Redefined in descendants as:
Determine whether or not the database engine supports UTF-8 character encoding.
boolean
hasUTFSupport
()
Method to get the auto-incremented value from the last INSERT statement.
mixed
insertid
()
Redefined in descendants as:
Inserts a row into a table based on an object's properties.
boolean
insertObject
(string $table, object &$object, [string $key = null])
-
string
$table: The name of the database table to insert into.
-
object
&$object: A reference to an object whose public properties match the table fields.
-
string
$key: The name of the primary key. If provided the object property is updated.
Redefined in descendants as:
Method to check whether the installed database version is supported by the database driver
boolean
isMinimumVersion
()
Method to get the first row of the result set from the database query as an associative array of ['field_name' => 'row_value'].
mixed
loadAssoc
()
Method to get an array of the result set rows from the database query where each row is an associative array of ['field_name' => 'row_value']. The array of rows can optionally be keyed by a field name, but defaults to a sequential numeric array.
NOTE: Chosing to key the result array by a non-unique field name can result in unwanted behavior and should be avoided.
mixed
loadAssocList
([string $key = null], [string $column = null])
-
string
$key: The name of a field on which to key the result array.
-
string
$column: An optional column name. Instead of the whole row, only this column value will be in the result array.
Method to get an array of values from the $offset field in each row of the result set from the database query.
mixed
loadColumn
([integer $offset = 0])
-
integer
$offset: The row offset to use to build the result array.
Method to get the next row in the result set from the database query as an object.
mixed
loadNextObject
([string $class = 'stdClass'])
-
string
$class: The class name to use for the returned row object.
Redefined in descendants as:
Method to get the next row in the result set from the database query as an array.
mixed
loadNextRow
()
Redefined in descendants as:
Method to get the first row of the result set from the database query as an object.
mixed
loadObject
([string $class = 'stdClass'])
-
string
$class: The class name to use for the returned row object.
Method to get an array of the result set rows from the database query where each row is an object. The array of objects can optionally be keyed by a field name, but defaults to a sequential numeric array.
NOTE: Choosing to key the result array by a non-unique field name can result in unwanted behavior and should be avoided.
mixed
loadObjectList
([string $key = ''], [string $class = 'stdClass'])
-
string
$key: The name of a field on which to key the result array.
-
string
$class: The class name to use for the returned row objects.
Method to get the first field of the first row of the result set from the database query.
mixed
loadResult
()
Redefined in descendants as:
Method to get the first row of the result set from the database query as an array. Columns are indexed numerically so the first column in the result set would be accessible via $row[0], etc.
mixed
loadRow
()
Method to get an array of the result set rows from the database query where each row is an array. The array of objects can optionally be keyed by a field offset, but defaults to a sequential numeric array.
NOTE: Choosing to key the result array by a non-unique field can result in unwanted behavior and should be avoided.
mixed
loadRowList
([string $key = null])
-
string
$key: The name of a field on which to key the result array.
Locks a table in the database.
-
string
$tableName: The name of the table to unlock.
Redefined in descendants as:
Quotes and optionally escapes a string to database requirements for use in database queries.
string
quote
(mixed $text, [boolean $escape = true])
-
mixed
$text: A string or an array of strings to quote.
-
boolean
$escape: True (default) to escape the string, false to leave it unchanged.
Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection risks and reserved word conflicts.
mixed
quoteName
(mixed $name, [mixed $as = null])
-
mixed
$name: The identifier name to wrap in quotes, or an array of identifier names to wrap in quotes. Each type supports dot-notation name.
-
mixed
$as: The AS query part associated to $name. It can be string or array, in latter case it has to be same length of $name; if is null there will not be any AS part for string or array element.
Quote strings coming from quoteName call.
string
quoteNameStr
(array $strArr)
-
array
$strArr: Array of strings coming from quoteName dot-explosion.
Renames a table in the database.
JDatabaseDriver
renameTable
(
string $oldTable,
string $newTable, [
string $backup =
null], [
string $prefix =
null])
-
string
$oldTable: The name of the table to be renamed
-
string
$newTable: The new name for the table.
-
string
$backup: Table prefix
-
string
$prefix: For the table - used to rename constraints in non-mysql databases
Redefined in descendants as:
This function replaces a string identifier $prefix with the string held is the tablePrefix class variable.
string
replacePrefix
(string $sql, [string $prefix = '#__'])
-
string
$sql: The SQL statement to prepare.
-
string
$prefix: The common table prefix.
Redefined in descendants as:
Select a database for use.
boolean
select
(string $database)
-
string
$database: The name of the database to select for use.
Redefined in descendants as:
Sets the database debugging state for the driver.
boolean
setDebug
(boolean $level)
-
boolean
$level: True to enable debugging.
Sets the SQL statement string for later execution.
JDatabaseDriver
setQuery
(
mixed $query, [
integer $offset =
0], [
integer $limit =
0])
-
mixed
$query: The SQL statement to set either as a JDatabaseQuery object or a string.
-
integer
$offset: The affected row offset to set.
-
integer
$limit: The maximum affected rows to set.
Redefined in descendants as:
Set the connection to use UTF-8 character encoding.
boolean
setUTF
()
Redefined in descendants as:
Method to commit a transaction.
void
transactionCommit
([boolean $toSavepoint = false])
-
boolean
$toSavepoint: If true, commit to the last savepoint.
Redefined in descendants as:
Method to roll back a transaction.
void
transactionRollback
([boolean $toSavepoint = false])
-
boolean
$toSavepoint: If true, rollback to the last savepoint.
Redefined in descendants as:
Method to initialize a transaction.
void
transactionStart
([boolean $asSavepoint = false])
-
boolean
$asSavepoint: If true and a transaction is already active, a savepoint will be created.
Redefined in descendants as:
Method to truncate a table.
void
truncateTable
(string $table)
-
string
$table: The table to truncate
Unlocks tables in the database.
Redefined in descendants as:
Updates a row in a table based on an object's properties.
boolean
updateObject
(string $table, object &$object, array $key, [boolean $nulls = false])
-
string
$table: The name of the database table to update.
-
object
&$object: A reference to an object whose public properties match the table fields.
-
array
$key: The name of the primary key.
-
boolean
$nulls: True to update null fields or false to ignore them.
Redefined in descendants as:
Magic method to provide method alias support for quote() and quoteName().
mixed
__call
(string $method, array $args)
-
string
$method: The called method.
-
array
$args: The array of arguments passed to the method.
Inherited Methods
Inherited From JDatabase
JDatabase::getConnectors()
JDatabase::getErrorMsg()
JDatabase::getErrorNum()
JDatabase::getInstance()
JDatabase::query()
JDatabase::splitSql()
JDatabase::stderr()
JDatabase::test()