The following is a online reference copy of the phpBB 2.0 Database Abstraction Layer manual. It is also available for download in zip format.

phpBB 2.0 Database Abstraction Layer

Variable Reference

There are a number of variables available to coders using the phpBB Database Abstraction Layer.

A summary of these variables and when they are available follows. All data in this section is based on phpBB 2.0.6 DBAL files (but is consistent across most phpBB 2.0 versions). Each variable is described in the following manner.

Variable Name ($db->whatever_it_is_called)
Supported Database Layers (The database types for which this variable is available.)
Description (What the variable stores, and what that can be used to accomplish.)

Also, please see these special notes about some variables.

Variable Index

These variables are available at all times after a database connection has been established.

  1. db_connect_id
  2. num_queries

The following variables are present in only some of the DBAL files. Since they are not supported for all databases, using them directly in code may produce incorrect results. Many of these correspond to DBAL functions that should be used instead.

  1. row
  2. rowset
  3. query_result
  4. in_transaction
  5. next_id
  6. result
  7. current_row
  8. field_names
  9. field_types
  10. num_rows
  11. result_rowset
  12. limit_offset
  13. row_index

The following variables are present in some DBAL files, but are not used.

  1. result_ids
  2. query_limit_success
  3. last_query_text
  4. query_numrows
  5. query_resultset

About Oracle

Please note that references to the DBAL for Oracle databases are included, but official support for Oracle was removed in phpBB 2.0.14.

Back to Top | Back to Variable Index
$db->db_connect_id
All

Stores a connection resource or link identifier associated with the database connection. This can be used in functions that access the database and to check for a valid database connection.

Back to Top | Back to Variable Index
$db->num_queries
All

Stores the total number of queries that have been executed in the script at this point. Useful in "page generation time" type scripts.

Back to Top | Back to Variable Index
$db->row
MySQL 3, MySQL 4, MS SQL, PostgreSQL, Oracle, ODBC

An array holding a single result row from a query. Cannot be used until the sql_fetchrow function has been called, so it is better to use that function to store the row in your own variable.

Back to Top | Back to Variable Index
$db->rowset
MySQL 3, MySQL 4, MS SQL, PostgreSQL, Oracle, ODBC

An array used to hold a single result row from a query. The row is then added to an array of all the result rows. Internal use varies for some database types, so use the sql_fetchrowset function instead of accessing this variable directly.

Back to Top | Back to Variable Index
$db->query_result
MySQL 3, MySQL 4, PostgreSQL, Oracle, ODBC

Stores a resource link identifier associated with the result of an SQL query. Can be used in functions that access the result of a query or check for a valid result. See also: $db->result.

Back to Top | Back to Variable Index
$db->in_transaction
MySQL 4, MS SQL, Oracle, PostgreSQL

Used to indicate if an SQL transaction is in progress.

Back to Top | Back to Variable Index
$db->next_id
MS Access, MS SQL, MS SQL (ODBC), ODBC

Stores the ID number generated by a query. Examples would be user ID numbers. topic ID numbers, etc. This variable should not be used outside of the DBAL. Use the sql_nextid function instead.

Back to Top | Back to Variable Index
$db->result
MS Access, MS SQL, MS SQL (ODBC)

Stores a resource link identifier associated with the result of an SQL query. Can be used in functions that access the result of a query or check for a valid result. See also: $db->query_result.

Back to Top | Back to Variable Index
$db->current_row
MS Access, MS SQL (ODBC)

Holds the row number of the current row. Can be used in functions that change this number (e.g., for skipping or repeating rows).

Back to Top | Back to Variable Index
$db->field_names
MS Access, MS SQL (ODBC)

An array storing the names of fields contained in a result. Can be used for displaying this information, among other things. There are DBAL functions that could also be used for this purpose.

Back to Top | Back to Variable Index
$db->field_types
MS Access, MS SQL (ODBC)

An array storing the types of fields contained in a result. Can be used for displaying this information, among other things. There are DBAL functions that could also be used for this purpose.

Back to Top | Back to Variable Index
$db->num_rows
MS Access, MS SQL (ODBC)

Stores the number of rows returned or affected by a query. Also used to determine the number of of rows to return when LIMIT is used in a query. This variable should not be used outside of the DBAL. Use the sql_numrows function instead.

Back to Top | Back to Variable Index
$db->result_rowset
MS Access, MS SQL (ODBC)

Stores a set of result rows from a query. Could be used to process an entire set of results at once. This variable should not be used outside of the DBAL. Use the sql_fetchrowset function instead.

Back to Top | Back to Variable Index
$db->limit_offset
MS SQL

Used to store the offset that should be used to limit results used. Use is not recommended.

Back to Top | Back to Variable Index
$db->row_index
ODBC

Holds the row number of the current row. Can be used in functions that change this number (e.g., for skipping or repeating rows).

Back to Top | Back to Variable Index
$db->result_ids
MS Access

Unknown. It does not appear to be used anywhere in phpBB.

Back to Top | Back to Variable Index
$db->query_limit_success
MS SQL

Unknown. It does not appear to be used anywhere in phpBB.

Back to Top | Back to Variable Index
$db->last_query_text
Oracle

Unknown.

Back to Top | Back to Variable Index
$db->query_numrows
ODBC

Unknown. It does not appear to be used anywhere in phpBB.

Back to Top | Back to Variable Index
$db->query_resultset
ODBC

Unknown. It does not appear to be used anywhere in phpBB.

Back to Top | Back to Variable Index
© 2003, 2005 Jeremy Rogers, all rights reserved. See details in About this Manual.