Joomla! 1.5 API

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2011 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.

Abstract Class JDatabase

Description

Database connector class

  • abstract:
  • since: 1.0

Located in /joomla/database/database.php (line 26)

Class JObject   (Subpackage Base)

Abstract class JDatabase   (Subpackage Database)
Direct descendents
Class Description
ClassJDatabaseMySQLi MySQLi database driver
ClassJDatabaseMySQL MySQL database driver
Variable Summary
Variable string $name
Variable resource $_cursor
Variable boolean $_debug
Variable string $_errorMsg
Variable int $_limit
Variable array $_log
Variable string $_nameQuote
Variable string $_nullDate
Variable int $_offset
Variable array $_quoted
Variable resource $_resource
Variable string $_sql
Variable int $_ticker
Variable boolean $_utf
Method Summary
Static method static boolean test ()
Constructor JDatabase __construct (array $options)
Method void addQuoted (mixed $quoted)
Method void BeginTrans ()
Method void CommitTrans ()
Method boolean connected ()
Method void debug (int $level)
Method void ErrorMsg ()
Method void ErrorNo ()
Method object Execute (string $query)
Abstract method void explain ()
Method void GenID ([ $foo1 = null], [ $foo2 = null])
Method void GetCol (string $query)
Abstract method string getCollation ()
Method array getConnectors ()
Method string getErrorMsg ([ $escaped = false])
Method int getErrorNum ()
Abstract method string getEscaped (string $text, [boolean $extra = false])
Method JDatabase &getInstance ([array $options = array()])
Method array getLog ()
Method string getNullDate ()
Abstract method int getNumRows ([object Database $cur = null])
Method mixed GetOne (string $query)
Method string getPrefix ()
Method string getQuery ()
Method array GetRow (string $query)
Abstract method array getTableCreate (array|string $tables)
Abstract method array getTableFields (array|string $tables, [boolean $typeonly = true])
Abstract method array getTableList ()
Method array getTicker ()
Method boolean getUTFSupport ()
Abstract method void getVersion ()
Abstract method boolean hasUTF ()
Abstract method mixed insertid ()
Method void insertObject (string $table, object An &$object, [string $keyName = NULL])
Method bool isQuoted (string $fieldName)
Abstract method void loadAssoc ()
Abstract method array loadAssocList ([string $key = ''])
Abstract method void loadObject (object 0)
Abstract method array loadObjectList ([string $key = ''])
Abstract method The loadResult ()
Abstract method void loadResultArray ([ $numinarray = 0])
Abstract method The loadRow ()
Abstract method array loadRowList ([string $key = ''])
Method string nameQuote (string $s)
Method void PageExecute ( $sql,  $nrows,  $page, [ $inputarr = false], [ $secs2cache = 0])
Abstract method mixed query ()
Abstract method mixed queryBatch ([ $abort_on_error = true], [ $p_transaction_safe = false])
Method string Quote (string $text, [boolean $escaped = true])
Method void replacePrefix (string $sql, [string $prefix = '#__'])
Method void RollbackTrans ()
Method void SelectLimit ( $query,  $count, [ $offset = 0])
Method void setQuery (string $sql, [string $offset = 0], [string $limit = 0], [string $prefix = '#__'])
Abstract method void setUTF ()
Method array splitSql (string $queries)
Method string stderr ([boolean $showSQL = false])
Abstract method void updateObject (string $table, object &$object, string $keyName, [boolean $updateNulls = true])
Variables
string $name = '' (line 33)

The database driver name


Redefined in descendants as:
resource $_cursor = null (line 75)

The last query cursor

boolean $_debug = 0 (line 82)

Debug option

string $_errorMsg = '' (line 54)

The database error message

int $_errorNum = 0 (line 47)

The database error number

bool $_hasQuoted = null (line 148)

Legacy compatibility

  • since: 1.5
int $_limit = 0 (line 89)

The limit for the query

array $_log = null (line 110)

A log of queries

string $_nameQuote = null (line 124)

Quote for named objects


Redefined in descendants as:
string $_nullDate = null (line 117)

The null/zero date string


Redefined in descendants as:
int $_offset = 0 (line 96)

The for offset for the limit

array $_quoted = null (line 140)

The fields that are to be quote

  • since: 1.5
resource $_resource = '' (line 68)

The connector resource

string $_sql = '' (line 40)

The query sql string

string $_table_prefix = '' (line 61)

The prefix used on all database tables

int $_ticker = 0 (line 103)

The number of queries performed by the object instance

boolean $_utf = 0 (line 132)

UTF-8 support

  • since: 1.5

Inherited Variables

Inherited from JObject

Variable JObject::$_errors
Methods
Constructor __construct (line 157)

Database object constructor

  • since: 1.5
  • access: public
JDatabase __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:
addQuoted (line 333)

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)
  • mixed $quoted: Field name or array of names
BeginTrans (line 1039)

ADODB compatability function

  • since: 1.5
void BeginTrans ()
CommitTrans (line 1057)

ADODB compatability function

  • since: 1.5
void CommitTrans ()
connected (line 299)

Determines if the connection to the server is active.

  • since: 1.5
  • access: public
boolean connected ()

Redefined in descendants as:
debug (line 409)

Sets the debug level on or off

  • access: public
void debug (int $level)
  • int $level: 0 = off, 1 = on
ErrorMsg (line 1066)

ADODB compatability function

  • since: 1.5
void ErrorMsg ()
ErrorNo (line 1076)

ADODB compatability function

  • since: 1.5
void ErrorNo ()
Execute (line 956)

ADODB compatability function

  • since: 1.5
  • access: public
object Execute (string $query)
  • string $query: SQL
explain (line 682)

Diagnostic function

  • abstract:
  • access: public
void explain ()

Redefined in descendants as:
GenID (line 1086)

ADODB compatability function

  • since: 1.5
void GenID ([ $foo1 = null], [ $foo2 = null])
  • $foo1
  • $foo2
getAffectedRows (line 659)

Get the affected rows by the most recent query

  • return: The number of affected rows in the previous operation
  • abstract:
  • since: 1.0.5
  • access: public
int getAffectedRows ()

Redefined in descendants as:
GetCol (line 942)

ADODB compatability function

  • since: 1.5
  • access: public
void GetCol (string $query)
  • string $query: SQL
getCollation (line 864)

Get the database collation

  • return: Collation in use
  • abstract:
  • access: public
string getCollation ()

Redefined in descendants as:
getConnectors (line 257)

Get the database connectors

  • return: An array of available session handlers
  • access: public
array getConnectors ()
getErrorMsg (line 441)

Get the error message

  • return: The error message for the most recent query
  • access: public
string getErrorMsg ([ $escaped = false])
  • $escaped
getErrorNum (line 430)

Get the error number

  • return: The error number for the most recent query
  • access: public
int getErrorNum ()
getEscaped (line 459)

Get a database escaped string

  • abstract:
  • access: public
string 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:
getInstance (line 194)

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
JDatabase &getInstance ([array $options = array()])
  • array $options: Parameters to be passed to the database driver
getLog (line 470)

Get a database error log

  • access: public
array getLog ()
getNullDate (line 526)

Get the database null date

  • return: Quoted null/zero date string
  • access: public
string getNullDate ()
getNumRows (line 695)

Get the number of rows returned by the most recent query

  • return: The number of rows
  • abstract:
  • access: public
int getNumRows ([object Database $cur = null])
  • object Database $cur: resource

Redefined in descendants as:
GetOne (line 1027)

ADODB compatability function

  • since: 1.5
  • access: public
mixed GetOne (string $query)
  • string $query: SQL
getPrefix (line 515)

Get the database table prefix

  • return: The database prefix
  • access: public
string getPrefix ()
getQuery (line 634)

Get the active query

  • return: The current value of the internal SQL vairable
  • access: public
string getQuery ()
GetRow (line 1012)

ADODB compatability function

  • since: 1.5
  • access: public
array GetRow (string $query)
  • string $query: SQL
getTableCreate (line 899)

Shows the CREATE TABLE statement that creates the given tables

  • return: A list the create SQL for the tables
  • abstract:
  • access: public
array getTableCreate (array|string $tables)
  • array|string $tables: A table name or a list of table names

Redefined in descendants as:
getTableFields (line 913)

Retrieves information about the given tables

  • return: An array of fields by table
  • abstract:
  • access: public
array 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:
getTableList (line 886)

List tables in a database

  • return: A list of all the tables in the database
  • abstract:
  • access: public
array getTableList ()

Redefined in descendants as:
getTicker (line 481)

Get the total number of queries made

  • access: public
array getTicker ()
getUTFSupport (line 420)

Get the database UTF-8 support

  • since: 1.5
  • access: public
boolean getUTFSupport ()
getVersion (line 874)

Get the version of the database connector

  • abstract:
void getVersion ()

Redefined in descendants as:
hasUTF (line 312)

Determines UTF support

  • abstract:
  • since: 1.5
  • access: public
boolean hasUTF ()

Redefined in descendants as:
insertid (line 852)

Get the ID generated from the previous INSERT operation

  • abstract:
  • access: public
mixed insertid ()

Redefined in descendants as:
insertObject (line 808)

Inserts a row into a table based on an objects properties

void 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:
isQuoted (line 394)

Checks if field name needs to be quoted

  • access: public
bool isQuoted (string $fieldName)
  • string $fieldName: The field name
loadAssoc (line 727)

Fetch a result row as an associative array

  • abstract:
void loadAssoc ()

Redefined in descendants as:
loadAssocList (line 740)

Load a associactive list of database rows

  • return: If key is empty as sequential list of returned records.
  • abstract:
  • access: public
array loadAssocList ([string $key = ''])
  • string $key: The field name of a primary key

Redefined in descendants as:
loadObject (line 753)

This global function loads the first row of a query into an object

  • abstract:
  • access: public
void loadObject (object 0)
  • object 0

Redefined in descendants as:
loadObjectList (line 769)

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.
  • abstract:
  • access: public
array loadObjectList ([string $key = ''])
  • string $key: The field name of a primary key

Redefined in descendants as:
loadResult (line 707)

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.
  • abstract:
  • access: public
The loadResult ()

Redefined in descendants as:
loadResultArray (line 717)

Load an array of single field results into an array

  • abstract:
void loadResultArray ( $numinarray)
  • $numinarray

Redefined in descendants as:
loadRow (line 781)

Load the first row returned by the query

  • return: first row of the query.
  • abstract:
  • access: public
The loadRow ()

Redefined in descendants as:
loadRowList (line 797)

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.

  • abstract:
  • access: public
array loadRowList ([string $key = ''])
  • string $key: The field name of a primary key

Redefined in descendants as:
nameQuote (line 493)

Quote an identifier name (field, table, etc)

  • return: The quoted name
  • access: public
string nameQuote (string $s)
  • string $s: The name
PageExecute (line 996)

ADODB compatability function

  • since: 1.5
  • access: public
void PageExecute ( $sql,  $nrows,  $page, [ $inputarr = false],  $secs2cache)
  • $sql
  • $nrows
  • $page
  • $inputarr
  • $secs2cache
query (line 646)

Execute the query

  • return: A database resource if successful, FALSE if not.
  • abstract:
  • access: public
mixed query ()

Redefined in descendants as:
queryBatch (line 671)

Execute a batch query

  • return: A database resource if successful, FALSE if not.
  • abstract:
  • access: public
mixed queryBatch ([ $abort_on_error = true], [ $p_transaction_safe = false])
  • $abort_on_error
  • $p_transaction_safe

Redefined in descendants as:
Quote (line 930)

Get a quoted database escaped string

  • access: public
string Quote (string $text, [boolean $escaped = true])
  • string $text: A string
  • boolean $escaped: Default true to escape string, false to leave the string unchanged
replacePrefix (line 558)

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 = '#__'])
  • string $sql: The SQL query
  • string $prefix: The common table prefix
RollbackTrans (line 1048)

ADODB compatability function

  • since: 1.5
void RollbackTrans ()
SelectLimit (line 981)

ADODB compatability function

  • since: 1.5
  • access: public
void SelectLimit ( $query,  $count,  $offset)
  • $query
  • $count
  • $offset
setQuery (line 543)

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 = '#__'])
  • 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
setUTF (line 323)

Custom settings for UTF support

  • abstract:
  • since: 1.5
  • access: public
void setUTF ()

Redefined in descendants as:
splitSql (line 350)

Splits a string of queries into an array of individual queries

  • return: queries
  • access: public
array splitSql (string $queries)
  • string $queries: The queries to split
stderr (line 834)

Print out an error statement

  • return: A standised error message
string stderr ([boolean $showSQL = false])
  • boolean $showSQL: If TRUE, displays the last SQL statement sent to the database
test (line 287)

Test to see if the MySQLi connector is available

  • return: True on success, false otherwise.
  • access: public
boolean test ()

Redefined in descendants as:
updateObject (line 823)

Update an object in the database

  • abstract:
  • access: public
void updateObject (string $table, object &$object, string $keyName, [boolean $updateNulls = true])
  • string $table
  • object &$object
  • string $keyName
  • boolean $updateNulls

Redefined in descendants as:

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()
Support Joomla!