Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5

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 Internal $_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 Internal $_resource
Variable string $_sql
Variable int $_ticker
Variable boolean $_utf
Method Summary
Constructor JDatabase __construct ([string $host = 'localhost'], string $user, string $pass, [string $db = ''], [string $table_prefix = ''])
Method void addQuoted (mixed $quoted)
Method void BeginTrans ()
Method void CommitTrans ()
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 string getErrorMsg ([ $escaped = false])
Method int getErrorNum ()
Abstract method string getEscaped ( $text)
Method JDatabase &getInstance ([string $driver = 'mysql'], [string $host = 'localhost'], string $user, string $pass, [string $db = ''], [string $table_prefix = ''])
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 $tables)
Abstract method array getTableFields (array $tables)
Abstract method array getTableList ()
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 ( $text)
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 29)
  • var: The database driver name

Redefined in descendants as:
Internal $_cursor = null (line 41)
  • var: variable to hold the last query cursor
boolean $_debug = 0 (line 43)
  • var: Debug option
string $_errorMsg = '' (line 35)
  • var: Internal variable to hold the database error message
int $_errorNum = 0 (line 33)
  • var: Internal variable to hold the database error number
bool $_hasQuoted = null (line 70)
  • var: Legacy compatibility
  • since: 1.5
int $_limit = 0 (line 45)
  • var: The limit for the query
array $_log = null (line 51)
  • var: A log of queries
string $_nameQuote = null (line 55)
  • var: Quote for named objects

Redefined in descendants as:
string $_nullDate = null (line 53)
  • var: The null/zero date string

Redefined in descendants as:
int $_offset = 0 (line 47)
  • var: The for offset for the limit
array $_quoted = null (line 65)
  • var: The fields that are to be quote
  • since: 1.5
Internal $_resource = '' (line 39)
  • var: variable to hold the connector resource
string $_sql = '' (line 31)
  • var: Internal variable to hold the query sql
string $_table_prefix = '' (line 37)
  • var: Internal variable to hold the prefix used on all database tables
int $_ticker = 0 (line 49)
  • var: A counter for the number of queries performed by the object instance
boolean $_utf = 0 (line 60)
  • var: UTF-8 support
  • since: 1.5
Methods
Constructor __construct (line 81)

Database object constructor

JDatabase __construct ([string $host = 'localhost'], string $user, string $pass, [string $db = ''], [string $table_prefix = ''])
  • string $host: Database host
  • string $user: Database user name
  • string $pass: Database user password
  • string $db: Database name
  • string $table_prefix: Common prefix for all tables

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.

Redefined in descendants as:
addQuoted (line 178)

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

ADODB compatability function

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

ADODB compatability function

  • since: 1.5
void CommitTrans ()
debug (line 210)

Sets the debug level on or off

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

ADODB compatability function

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

ADODB compatability function

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

ADODB compatability function

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

Diagnostic function

  • access: public
  • abstract:
void explain ()

Redefined in descendants as:
GenID (line 820)

ADODB compatability function

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

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

ADODB compatability function

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

Get the database collation

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

Redefined in descendants as:
getErrorMsg (line 242)

Get the error message

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

Get the error number

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

Get a database escaped string

  • access: public
  • abstract:
string getEscaped ( $text)
  • $text

Redefined in descendants as:
getInstance (line 117)

Returns a reference to the global Database object, only creating it if it doesn't already exist.

  • return: A database object
  • since: 1.5
JDatabase &getInstance ([string $driver = 'mysql'], [string $host = 'localhost'], string $user, string $pass, [string $db = ''], [string $table_prefix = ''])
  • string $driver: Database driver
  • string $host: Database host
  • string $user: Database user name
  • string $pass: Database user password
  • string $db: Database name
  • string $table_prefix: Common prefix for all tables
getNullDate (line 293)

Get the database null date

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

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

ADODB compatability function

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

Get the database table prefix

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

Get the active query

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

ADODB compatability function

  • since: 1.5
  • access: public
array GetRow (string $query)
  • string $query: SQL
getTableCreate (line 644)
  • return: A list the create SQL for the tables
  • access: public
  • abstract:
array getTableCreate (array $tables)
  • array $tables: A list of table names

Redefined in descendants as:
getTableFields (line 656)

List database table fields

  • return: An array of fields by table
  • access: public
  • abstract:
array getTableFields (array $tables)
  • array $tables: A list of table names

Redefined in descendants as:
getTableList (line 632)

List tables in a database

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

Redefined in descendants as:
getUTFSupport (line 221)

Get the database UTF-8 support

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

Get the version of the database connector

  • abstract:
void getVersion ()

Redefined in descendants as:
hasUTF (line 157)

Determines UTF support

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

Redefined in descendants as:
insertid (line 601)

Get the ID generated from the previous INSERT operation

  • access: public
  • abstract:
mixed insertid ()

Redefined in descendants as:
insertObject (line 560)

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

Checks if field name needs to be quoted

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

Fetch a result row as an associative array

  • abstract:
void loadAssoc ()

Redefined in descendants as:
loadAssocList (line 497)

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

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

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

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

Load an array of single field results into an array

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

Redefined in descendants as:
loadRow (line 535)

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

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

Quote an identifier name (field, table, etc)

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

ADODB compatability function

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

Execute the query

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

Redefined in descendants as:
queryBatch (line 434)

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

Get a quoted database escaped string

  • access: public
string Quote ( $text)
  • $text
replacePrefix (line 324)

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

ADODB compatability function

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

ADODB compatability function

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

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

Custom settings for UTF support

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

Redefined in descendants as:
stderr (line 584)

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
updateObject (line 574)

Update ab object in the database

  • access: public
  • abstract:
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::getPublicProperties()
 JObject::set()
 JObject::toString()

Documentation generated on Mon, 05 Mar 2007 20:56:05 +0000 by phpDocumentor 1.3.1