From Joomla! Documentation

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

JDatabase is an abstract class which is extended by specific database drivers. It provides database connections for Joomla.

Defined in[edit]



Method name Description
__construct Database object constructor
__destruct Database object destructor
getConnectors Get the database connectors
test Test to see if the MySQLi connector is available
connected Determines if the connection to the server is active.
hasUTF Determines UTF support
setUTF Custom settings for UTF support
addQuoted Adds a field or array of field names to the list that are to be quoted
splitSql Splits a string of queries into an array of individual queries
isQuoted Checks if field name needs to be quoted
debug Sets the debug level on or off
getUTFSupport Get the database UTF-8 support
getErrorNum Get the error number
getErrorMsg Get the error message
getEscaped Get a database escaped string
getLog Get a database error log
getTicker Get the total number of queries made
nameQuote Quote an identifier name (field, table, etc)
getPrefix Get the database table prefix
getConnection Get the connection
getNullDate Get the database null date
setQuery Sets the SQL query string for later execution.
replacePrefix This function replaces a string identifier $prefix with the string held is the _table_prefix class variable.
getQuery Get the current or query, or new JDatabaseQuery object.
query Execute the query
getAffectedRows Get the affected rows by the most recent query
queryBatch Execute a batch query
explain Diagnostic function
getNumRows Get the number of rows returned by the most recent query
loadResult This method loads the first field of the first row returned by the query.
loadResultArray Load an array of single field results into an array
loadAssoc Fetch a result row as an associative array
loadAssocList Load a associactive list of database rows
loadObject This global function loads the first row of a query into an object
loadObjectList Load a list of database objects
loadRow Load the first row returned by the query
loadRowList Load a list of database rows (numeric column indexing)
loadNextRow Load the next row returned by the query.
loadNextObject Load the next row returned by the query.
insertObject Inserts a row into a table based on an objects properties
updateObject Update an object in the database
stderr Print out an error statement
insertid Get the ID generated from the previous INSERT operation
getCollation Get the database collation
getVersion Get the version of the database connector
getTableList List tables in a database
getTableCreate Shows the CREATE TABLE statement that creates the given tables
getTableFields Retrieves information about the given tables
quote Get a quoted database escaped string
getInstance Returns the global Database object, only creating it if it doesn't already exist.


jimport( 'joomla.database.database' );


Code Examples[edit]