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
()
Method to return a JDatabase 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 'mysql'. 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.
static
JDatabase
getInstance
([
array $options =
array()])
-
array
$options: Parameters to be passed to the database driver.
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.
Constructor.
JDatabase
__construct
(array $options)
-
array
$options: List of options used to configure the connection
Redefined in descendants as:
Adds a field or array of field names to the list that are to be quoted.
void
addQuoted
(mixed $quoted)
-
mixed
$quoted: Field name or array of names.
Determines if the connection to the server is active.
boolean
connected
()
Redefined in descendants as:
Sets the debug level on or off
void
debug
(integer $level)
-
integer
$level:
- to disable debugging and 1 to enable it.
Drops a table from the database.
JDatabase
dropTable
(
string $table, [
boolean $ifExists =
true])
-
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:
Method to escape 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:
Diagnostic method to return explain information for a query.
string
explain
()
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:
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
()
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
()
Gets the error message from the database connection.
string
getErrorMsg
([boolean $escaped = false])
-
boolean
$escaped: True to escape the message string for use in JavaScript.
Gets the error number from the database connection.
integer
getErrorNum
()
Method to escape a string for usage in an SQL statement.
string
getEscaped
(string $text, [boolean $extra = false])
-
string
$text: The string to be escaped.
-
boolean
$extra: Optional parameter to provide extra escaping.
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
getTableFields
(mixed $tables, [boolean $typeOnly = true])
-
mixed
$tables: A table name or a list of table names.
-
boolean
$typeOnly: True to only return field types.
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 total number of SQL statements executed by the database driver.
integer
getTicker
()
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:
Determines if the database engine supports UTF-8 character encoding.
boolean
hasUTF
()
Redefined in descendants as:
Method to get the auto-incremented value from the last INSERT statement.
integer
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
()
Checks if field name needs to be quoted.
bool
isQuoted
(string $field)
-
string
$field: The field name to be checked.
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.
Method to get the next row in the result set from the database query as an array.
mixed
loadNextRow
()
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 an array of values from the $offset field in each row of the result set from the database query.
mixed
loadResultArray
([integer $offset = 0])
-
integer
$offset: The row offset to use to build the result array.
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:
Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection risks and reserved word conflicts.
string
nameQuote
(string $name)
-
string
$name: The identifier name to wrap in quotes.
Execute the SQL statement.
mixed
query
()
Execute a query batch.
mixed
queryBatch
([boolean $abortOnError = true], [boolean $transactionSafe = false])
-
boolean
$abortOnError: Abort on error.
-
boolean
$transactionSafe: Transaction safe queries.
Redefined in descendants as:
Method to quote and optionally escape a string to database requirements for insertion into the database.
string
quote
(string $text, [boolean $escape = true])
-
string
$text: The string to quote.
-
boolean
$escape: True (default) to escape the string, false to leave it unchanged.
Redefined in descendants as:
-
JDatabaseSQLSrv::quote()
: Method to quote and optionally escape a string to database requirements for insertion into the database.
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.
JDatabase
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.
JDatabase
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.
Set the connection to use UTF-8 character encoding.
boolean
setUTF
()
Redefined in descendants as:
Return the most recent error message for the database connector.
string
stderr
([boolean $showSQL = false])
-
boolean
$showSQL: True to display the SQL statement sent to the database as well as the error.
Method to commit a transaction.
void
transactionCommit
()
Redefined in descendants as:
Method to roll back a transaction.
void
transactionRollback
()
Redefined in descendants as:
Method to initialize a transaction.
void
transactionStart
()
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, string $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.
-
string
$key: The name of the primary key.
-
boolean
$nulls: True to update null fields or false to ignore them.
Magic method to provide method alias support for quote() and quoteName().
string
__call
(string $method, array $args)
-
string
$method: The called method.
-
array
$args: The array of arguments passed to the method.