Friday, January 29, 2010
Joomla Database Commands
JDatabase
Description
Database connector class
- since: 1.0
- abstract:
Located in /joomla/database/database.php (line 26)
JObject (Subpackage Base)
![]()
JDatabase (Subpackage Database)
Direct descendents
| Class | Description |
|---|---|
JDatabaseMySQL | MySQL database driver |
JDatabaseMySQLi | MySQLi database driver |
Variable Summary
string $name
resource $_cursor
boolean $_debug
string $_errorMsg
int $_errorNum
bool $_hasQuoted
int $_limit
array $_log
string $_nameQuote
string $_nullDate
int $_offset
array $_quoted
resource $_resource
string $_sql
string $_table_prefix
int $_ticker
boolean$_utfMethod Summary
static boolean test ( )
JDatabase __construct (array $options)
void addQuoted (mixed $quoted)
void BeginTrans ( )
void CommitTrans ( )
boolean connected ( )
void debug ( int $level )
void ErrorMsg ( )
void ErrorNo ( )
object Execute (string $query)
void explain ( )
void GenID( [ $foo1 = null], [ $foo2 = null] )
int getAffectedRows ( )
void GetCol (string $query)
string getCollation ( )
array getConnectors ( )
void
updateObject
( string $table, object &$object, string $keyName, [boolean $updateNulls = true] )
Variables
The database driver name
Redefined in descendants as:
-
JDatabaseMySQL::$name
: The database driver name
-
JDatabaseMySQLi::$name
: The database driver name
Quote for named objects
Redefined in descendants as:
-
JDatabaseMySQL::$_nameQuote
: Quote for named objects
-
JDatabaseMySQLi::$_nameQuote
: Quote for named objects
The null/zero date string
Redefined in descendants as:
-
JDatabaseMySQL::$_nullDate
: The null/zero date string
-
JDatabaseMySQLi::$_nullDate
: The null/zero date string
Inherited Variables
Inherited from JObject
![]()
JObject::$_errors
Methods
Database object constructor
- since: 1.5
- access: public
JDatabase
__construct
(array $options)
__construct
(array $options)
-
array
$options: List of options used to configure the connection
Redefinition of:
- JObject::__construct()
- Class constructor, overridden in descendant classes.
Redefined in descendants as:
-
JDatabaseMySQL::__construct()
: Database object constructor
-
JDatabaseMySQLi::__construct()
: Database object constructor
Adds a field or array of field names to the list that are to be quoted
- since: 1.5
- access: public
void
addQuoted
(mixed $quoted)
addQuoted
(mixed $quoted)
-
mixed
$quoted: Field name or array of names
Determines if the connection to the server is active.
- since: 1.5
- access: public
boolean
connected
()
connected
()
Redefined in descendants as:
-
JDatabaseMySQL::connected()
: Determines if the connection to the server is active.
-
JDatabaseMySQLi::connected()
: Determines if the connection to the server is active.
Sets the debug level on or off
- access: public
void
debug
(int $level)
debug
(int $level)
-
int
$level: 0 = off, 1 = on
ADODB compatability function
- since: 1.5
- access: public
object
Execute
(string $query)
Execute
(string $query)
-
string
$query: SQL
Diagnostic function
- access: public
- abstract:
void
explain
()
explain
()
Redefined in descendants as:
-
JDatabaseMySQL::explain()
: Diagnostic function
-
JDatabaseMySQLi::explain()
: Diagnostic function
ADODB compatability function
- since: 1.5
void
GenID
([ $foo1 = null], [ $foo2 = null])
GenID
([ $foo1 = null], [ $foo2 = null])
-
$foo1 -
$foo2
Get the affected rows by the most recent query
- return: The number of affected rows in the previous operation
- since: 1.0.5
- access: public
- abstract:
int
getAffectedRows
()
getAffectedRows
()
Redefined in descendants as:
-
JDatabaseMySQL::getAffectedRows()
: Description
-
JDatabaseMySQLi::getAffectedRows()
: Description
ADODB compatability function
- since: 1.5
- access: public
void
GetCol
(string $query)
GetCol
(string $query)
-
string
$query: SQL
Get the database collation
- return: Collation in use
- access: public
- abstract:
string
getCollation
()
getCollation
()
Redefined in descendants as:
-
JDatabaseMySQL::getCollation()
: Assumes database collation in use by sampling one text field in one table
-
JDatabaseMySQLi::getCollation()
: Assumes database collation in use by sampling one text field in one table
Get the database connectors
- return: An array of available session handlers
- access: public
array
getConnectors
()
getConnectors
()
Get the error message
- return: The error message for the most recent query
- access: public
string
getErrorMsg
([ $escaped = false])
getErrorMsg
([ $escaped = false])
-
$escaped
Get the error number
- return: The error number for the most recent query
- access: public
int
getErrorNum
()
getErrorNum
()
Get a database escaped string
- abstract:
- access: public
string
getEscaped
(string $text, [boolean $extra = false])
getEscaped
(string $text, [boolean $extra = false])
-
string
$text: The string to be escaped -
boolean
$extra: Optional parameter to provide extra escaping
Redefined in descendants as:
-
JDatabaseMySQL::getEscaped()
: Get a database escaped string
-
JDatabaseMySQLi::getEscaped()
: Get a database escaped string
Returns a reference to the global Database object, only creating it if it doesn't already exist.
The 'driver' entry in the parameters array specifies the database driver to be used (defaults to 'mysql' if omitted). All other parameters are database driver dependent.- return: A database object
- since: 1.5
-
array
$options: Parameters to be passed to the database driver
Get the database null date
- return: Quoted null/zero date string
- access: public
string
getNullDate
()
getNullDate
()
Get the number of rows returned by the most recent query
- return: The number of rows
- access: public
- abstract:
int
getNumRows
([object Database $cur = null])
getNumRows
([object Database $cur = null])
-
object Database
$cur: resource
Redefined in descendants as:
-
JDatabaseMySQL::getNumRows()
: Description
-
JDatabaseMySQLi::getNumRows()
: Description
ADODB compatability function
- since: 1.5
- access: public
mixed
GetOne
(string $query)
GetOne
(string $query)
-
string
$query: SQL
Get the database table prefix
- return: The database prefix
- access: public
string
getPrefix
()
getPrefix
()
Get the active query
- return: The current value of the internal SQL vairable
- access: public
string
getQuery
()
getQuery
()
ADODB compatability function
- since: 1.5
- access: public
array
GetRow
(string $query)
GetRow
(string $query)
-
string
$query: SQL
Shows the CREATE TABLE statement that creates the given tables
- return: A list the create SQL for the tables
- access: public
- abstract:
array
getTableCreate
(array|string $tables)
getTableCreate
(array|string $tables)
-
array|string
$tables: A table name or a list of table names
Redefined in descendants as:
-
JDatabaseMySQL::getTableCreate()
: Shows the CREATE TABLE statement that creates the given tables
-
JDatabaseMySQLi::getTableCreate()
: Shows the CREATE TABLE statement that creates the given tables
Retrieves information about the given tables
- return: An array of fields by table
- access: public
- abstract:
array
getTableFields
(array|string $tables, [boolean $typeonly = true])
getTableFields
(array|string $tables, [boolean $typeonly = true])
-
array|string
$tables: A table name or a list of table names -
boolean
$typeonly: Only return field types, default true
Redefined in descendants as:
-
JDatabaseMySQL::getTableFields()
: Retrieves information about the given tables
-
JDatabaseMySQLi::getTableFields()
: Retrieves information about the given tables
List tables in a database
- return: A list of all the tables in the database
- access: public
- abstract:
array
getTableList
()
getTableList
()
Redefined in descendants as:
-
JDatabaseMySQL::getTableList()
: Description
-
JDatabaseMySQLi::getTableList()
: Description
Get the database UTF-8 support
- since: 1.5
- access: public
boolean
getUTFSupport
()
getUTFSupport
()
Get the version of the database connector
- abstract:
void
getVersion
()
getVersion
()
Redefined in descendants as:
-
JDatabaseMySQL::getVersion()
: Description
-
JDatabaseMySQLi::getVersion()
: Description
Determines UTF support
- since: 1.5
- access: public
- abstract:
boolean
hasUTF
()
hasUTF
()
Redefined in descendants as:
-
JDatabaseMySQL::hasUTF()
: Determines UTF support
-
JDatabaseMySQLi::hasUTF()
: Determines UTF support
Get the ID generated from the previous INSERT operation
- access: public
- abstract:
mixed
insertid
()
insertid
()
Redefined in descendants as:
-
JDatabaseMySQL::insertid()
: Description
-
JDatabaseMySQLi::insertid()
: Description
Inserts a row into a table based on an objects properties
void
insertObject
(string $table, object An &$object, [string $keyName = NULL])
insertObject
(string $table, object An &$object, [string $keyName = NULL])
-
string
$table: The name of the table -
object An
&$object: object whose properties match table fields -
string
$keyName: The name of the primary key. If provided the object property is updated.
Redefined in descendants as:
-
JDatabaseMySQL::insertObject()
: Inserts a row into a table based on an objects properties
-
JDatabaseMySQLi::insertObject()
: Inserts a row into a table based on an objects properties
Checks if field name needs to be quoted
- access: public
bool
isQuoted
(string $fieldName)
isQuoted
(string $fieldName)
-
string
$fieldName: The field name
Fetch a result row as an associative array
- abstract:
void
loadAssoc
()
loadAssoc
()
Redefined in descendants as:
-
JDatabaseMySQL::loadAssoc()
: Fetch a result row as an associative array
-
JDatabaseMySQLi::loadAssoc()
: Fetch a result row as an associative array
Load a associactive list of database rows
- return: If key is empty as sequential list of returned records.
- access: public
- abstract:
array
loadAssocList
([string $key = ''])
loadAssocList
([string $key = ''])
-
string
$key: The field name of a primary key
Redefined in descendants as:
-
JDatabaseMySQL::loadAssocList()
: Load a assoc list of database rows
-
JDatabaseMySQLi::loadAssocList()
: Load a assoc list of database rows
This global function loads the first row of a query into an object
- access: public
- abstract:
void
loadObject
(object 0)
loadObject
(object 0)
-
object
0
Redefined in descendants as:
-
JDatabaseMySQL::loadObject()
: This global function loads the first row of a query into an object
-
JDatabaseMySQLi::loadObject()
: This global function loads the first row of a query into an object
Load a list of database objects
- return: If key is empty as sequential list of returned records. If key is not empty then the returned array is indexed by the value the database key. Returns null if the query fails.
- access: public
- abstract:
array
loadObjectList
([string $key = ''])
loadObjectList
([string $key = ''])
-
string
$key: The field name of a primary key
Redefined in descendants as:
-
JDatabaseMySQL::loadObjectList()
: Load a list of database objects
-
JDatabaseMySQLi::loadObjectList()
: Load a list of database objects
This method loads the first field of the first row returned by the query.
- return: value returned in the query or null if the query failed.
- access: public
- abstract:
The
loadResult
()
loadResult
()
Redefined in descendants as:
-
JDatabaseMySQL::loadResult()
: This method loads the first field of the first row returned by the query.
-
JDatabaseMySQLi::loadResult()
: This method loads the first field of the first row returned by the query.
Load an array of single field results into an array
- abstract:
void
loadResultArray
( $numinarray)
loadResultArray
( $numinarray)
-
$numinarray
Redefined in descendants as:
-
JDatabaseMySQL::loadResultArray()
: Load an array of single field results into an array
-
JDatabaseMySQLi::loadResultArray()
: Load an array of single field results into an array
Load the first row returned by the query
- return: first row of the query.
- access: public
- abstract:
The
loadRow
()
loadRow
()
Redefined in descendants as:
-
JDatabaseMySQL::loadRow()
: Description
-
JDatabaseMySQLi::loadRow()
: Description
Load a list of database rows (numeric column indexing)
If key is not empty then the returned array is indexed by the value the database key. Returns null if the query fails.- access: public
- abstract:
array
loadRowList
([string $key = ''])
loadRowList
([string $key = ''])
-
string
$key: The field name of a primary key
Redefined in descendants as:
-
JDatabaseMySQL::loadRowList()
: Load a list of database rows (numeric column indexing)
-
JDatabaseMySQLi::loadRowList()
: Load a list of database rows (numeric column indexing)
Quote an identifier name (field, table, etc)
- return: The quoted name
- access: public
string
nameQuote
(string $s)
nameQuote
(string $s)
-
string
$s: The name
ADODB compatability function
- since: 1.5
- access: public
void
PageExecute
( $sql, $nrows, $page, [ $inputarr = false], $secs2cache)
PageExecute
( $sql, $nrows, $page, [ $inputarr = false], $secs2cache)
-
$sql -
$nrows -
$page -
$inputarr -
$secs2cache
Execute the query
- return: A database resource if successful, FALSE if not.
- access: public
- abstract:
mixed
query
()
query
()
Redefined in descendants as:
-
JDatabaseMySQL::query()
: Execute the query
-
JDatabaseMySQLi::query()
: Execute the query
Execute a batch query
- return: A database resource if successful, FALSE if not.
- access: public
- abstract:
mixed
queryBatch
([ $abort_on_error = true], [ $p_transaction_safe = false])
queryBatch
([ $abort_on_error = true], [ $p_transaction_safe = false])
-
$abort_on_error -
$p_transaction_safe
Redefined in descendants as:
-
JDatabaseMySQL::queryBatch()
: Execute a batch query
-
JDatabaseMySQLi::queryBatch()
: Execute a batch query
Get a quoted database escaped string
- access: public
string
Quote
(string $text, [boolean $escaped = true])
Quote
(string $text, [boolean $escaped = true])
-
string
$text: A string -
boolean
$escaped: Default true to escape string, false to leave the string unchanged
This function replaces a string identifier $prefix with the string held is the _table_prefix class variable.
- access: public
void
replacePrefix
(string $sql, [string $prefix = '#__'])
replacePrefix
(string $sql, [string $prefix = '#__'])
-
string
$sql: The SQL query -
string
$prefix: The common table prefix
ADODB compatability function
- since: 1.5
- access: public
void
SelectLimit
( $query, $count, $offset)
SelectLimit
( $query, $count, $offset)
-
$query -
$count -
$offset
Sets the SQL query string for later execution.
This function replaces a string identifier $prefix with the string held is the _table_prefix class variable.
- access: public
void
setQuery
(string $sql, string $offset, string $limit, [string $prefix = '#__'])
setQuery
(string $sql, string $offset, string $limit, [string $prefix = '#__'])
-
string
$sql: The SQL query -
string
$offset: The offset to start selection -
string
$limit: The number of results to return -
string
$prefix: The common table prefix
Custom settings for UTF support
- since: 1.5
- access: public
- abstract:
void
setUTF
()
setUTF
()
Redefined in descendants as:
-
JDatabaseMySQL::setUTF()
: Custom settings for UTF support
-
JDatabaseMySQLi::setUTF()
: Custom settings for UTF support
Splits a string of queries into an array of individual queries
- return: queries
- access: public
array
splitSql
(string $queries)
splitSql
(string $queries)
-
string
$queries: The queries to split
Print out an error statement
- return: A standised error message
string
stderr
([boolean $showSQL = false])
stderr
([boolean $showSQL = false])
-
boolean
$showSQL: If TRUE, displays the last SQL statement sent to the database
Test to see if the MySQLi connector is available
- return: True on success, false otherwise.
- access: public
boolean
test
()
test
()
Redefined in descendants as:
-
JDatabaseMySQL::test()
: Test to see if the MySQL connector is available
-
JDatabaseMySQLi::test()
: Test to see if the MySQLi connector is available
Update an object in the database
- access: public
- abstract:
void
updateObject
(string $table, object &$object, string $keyName, [boolean $updateNulls = true])
updateObject
(string $table, object &$object, string $keyName, [boolean $updateNulls = true])
-
string
$table -
object
&$object -
string
$keyName -
boolean
$updateNulls
Redefined in descendants as:
-
JDatabaseMySQL::updateObject()
: Description
-
JDatabaseMySQLi::updateObject()
: Description
Inherited Methods
Inherited From JObject
![]()
JObject::JObject()
![]()
JObject::__construct()
![]()
JObject::get()
![]()
JObject::getError()
![]()
JObject::getErrors()
![]()
JObject::getProperties()
![]()
JObject::getPublicProperties()
![]()
JObject::set()
![]()
JObject::setError()
![]()
JObject::setProperties()
![]()
JObject::toString()
Copyright
Some parts of this documentation was taken from http://api.joomla.org/Joomla-Framework/Database/JDatabase.html (© 2005 - 2008 Open Source Matters Inc) and is used withpermission granted by the Joomla! Electronic Documentation License v 1.0.
Joomla! Electronic Documentation License v 1.0
Definitions
To "Propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except displaying or modifying a private copy.
The "Work" is any copyrightable material licensed under the terms of this license or any material based on such material. The "Author" means all the people or entities who have the legal right to grant permission to Propagate the Work or parts of the Work. Each licensee is addressed as "you".
"Electronic Media" means any device, medium or technology used to store, record, display, transmit or modify electronic information, including websites, compact discs, digital video discs, hard disks, magnetic media, and computer networks. "Electronic Media" does not include, for example, books printed on paper.
"Grantback License" means a non-exclusive, perpetual, worldwide, royalty-free license to Propagate the Work in any medium and by any means.
"Copyleft License" means a license to Propagate the Work under the terms of this license or any future version of the Joomla Electronic Documentation License published by Open Source Matters, Incorporated.
The "Source Form" of a work means the preferred form of the Work for making modifications to it. For text works, this could be plain ASCII text format.
Conditional Permissions
If you grant a Grantback License to the Author and a Copyleft License to anybody who comes into possession of the Work, you may Propagate the Work via Electronic Media for any purpose, including commercial purposes.
You must make available at no charge to anybody to whom you distribute the Work a version of the Work in Source Form. Such availability must be via either (1) the same means and method with which you distribute the Work or (2) simple download over the internet. You may not condition providing the Source Form of the Work on anything other than acceptance of this license.
You must provide a copy of this license, notice that it applies to the Work, and information needed to acquire the Source Form to anybody to whom you distribute the Work.
You must preserve the Author's copyright notices in the Work and display them as prominently as you display your own.
Reservations of Rights
Nothing in this license grants you or anybody else any right to Propagate the Work in any medium or through any means other than Electronic Media.
Nothing in this license grants you or anybody else any right to do anything that requires permission under trademark law. Specifically, nothing in this license grants you permission to represent that the Work is "official" or in any way endorsed or sanctioned by the Authors.
Subscribe to:
Posts (Atom)
About Me
- Jack Briner
- I'm a Texan who is living in South Carolina. I love living in Charleston with its history and proximity to the water. I'm married to a Lutheran pastor. We have two teenagers and two dogs.
Some of my sites
Flowertown Technology LLC
- Virus: Fix Your Virus
- PC Repair:Fix Ya PC
- Hosting:Holy City Websites

JDatabase (Subpackage Database)