Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5. Some parts of this website may be subject to other licenses.

Abstract Class JDatabase

Description

Database connector class

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

Class JObject   (Subpackage Base)

Abstract class JDatabase   (Subpackage Database)
Direct descendents
Class Description
ClassJDatabaseMySQL MySQL database driver
ClassJDatabaseMySQLi MySQLi 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 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 988)

ADODB compatability function

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

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 365)

Sets the debug level on or off

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

ADODB compatability function

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

ADODB compatability function

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

ADODB compatability function

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

Diagnostic function

  • access: public
  • abstract:
void explain ()

Redefined in descendants as:
GenID (line 1035)

ADODB compatability function

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

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 ()

Redefined in descendants as:
GetCol (line 891)

ADODB compatability function

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

Get the database collation

  • return: Collation in use
  • access: public
  • abstract:
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 397)

Get the error message

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

Get the error number

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

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 426)

Get a database error log

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

Get the database null date

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

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])
  • object Database $cur: resource

Redefined in descendants as:
GetOne (line 976)

ADODB compatability function

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

Get the database table prefix

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

Get the active query

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

ADODB compatability function

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

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)
  • array|string $tables: A table name or a list of table names

Redefined in descendants as:
getTableFields (line 862)

Retrieves information about the given tables

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

List tables in a database

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

Redefined in descendants as:
getTicker (line 437)

Get the total number of queries made

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

Get the database UTF-8 support

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

Get the version of the database connector

  • abstract:
void getVersion ()

Redefined in descendants as:
hasUTF (line 312)

Determines UTF support

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

Redefined in descendants as:
insertid (line 801)

Get the ID generated from the previous INSERT operation

  • access: public
  • abstract:
mixed insertid ()

Redefined in descendants as:
insertObject (line 757)

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 350)

Checks if field name needs to be quoted

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

Fetch a result row as an associative array

  • abstract:
void loadAssoc ()

Redefined in descendants as:
loadAssocList (line 689)

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 = ''])
  • string $key: The field name of a primary key

Redefined in descendants as:
loadObject (line 702)

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

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

Redefined in descendants as:
loadObjectList (line 718)

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 = ''])
  • string $key: The field name of a primary key

Redefined in descendants as:
loadResult (line 656)

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 ()

Redefined in descendants as:
loadResultArray (line 666)

Load an array of single field results into an array

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

Redefined in descendants as:
loadRow (line 730)

Load the first row returned by the query

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

Redefined in descendants as:
loadRowList (line 746)

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 = ''])
  • string $key: The field name of a primary key

Redefined in descendants as:
nameQuote (line 449)

Quote an identifier name (field, table, etc)

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

ADODB compatability function

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

Execute the query

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

Redefined in descendants as:
queryBatch (line 620)

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])
  • $abort_on_error
  • $p_transaction_safe

Redefined in descendants as:
Quote (line 879)

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 507)

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 997)

ADODB compatability function

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

ADODB compatability function

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

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