DB_Base Class Reference

Inherited by DB_MSSQL, DB_MySQL, DB_ODBC, DB_PDO, DB_PostgreSQL, DB_SQLite, and DB_SQLite3.

List of all members.

Public Member Functions

 _catch ($msg="")
 error ($msg)
 build_sql ($select, $from, $where='', $group='', $having='', $order='', $limit='')
query ($query_str, $query_arg="", $bypass=false)
execute ($query_str, $query_arg="", $bypass=false)
get_item ($query_str, $query_arg="")
 get_item_by_pk ($table, $pk, $pk_col='id')
get_all ($query_str, $query_arg="", $key="")
get_value ($query_str, $query_arg="", $value="")
get_values ($query_str, $query_arg="", $value="")
get_item_pair ($query_str, $query_arg="")
get_all_pair ($query_str, $query_arg="")
 insert_all ($table, $data, $aFields="", $mode='insert')
 replace_all ($table, $data, $aFields="")
 update_all ($table, $data, $where="", $where_arg="", $aUpdateFields="")
 insert_row ($sTable, $aRow, $mode='insert')
 replace_row ($sTable, $aRow)
 update_row ($sTable, $aRow, $sWhere, $aWhereArgs=array())
 insert_update_row ($sTable, $aRow, $aKey)
 increment_row ($sTable, $sField, $aKey)

Public Attributes

 $conn
 $query
 $result
 $error
 $insert_id
 $echo = false
 $debug = false
 $profile = false
 $profile_data = array()

Detailed Description

PRONTO WEB FRAMEWORK Copyright (C) 2006, Judd Vinet

Author:
Judd Vinet <jvinet@zeroflux.org>

Description: DB interface, used by models and page controllers.

Definition at line 12 of file db.php.


Member Function Documentation

DB_Base::_catch ( msg = ""  ) 

Exception/error catcher

Parameters:
string $msg

Reimplemented in DB_MSSQL, DB_MySQL, DB_ODBC, DB_PDO, DB_PostgreSQL, DB_SQLite, and DB_SQLite3.

Definition at line 29 of file db.php.

References error().

Referenced by execute().

DB_Base::build_sql ( select,
from,
where = '',
group = '',
having = '',
order = '',
limit = '' 
)

Generate a SQL string by stitching together SQL chunks

Parameters:
string $select
string $from
string $where
string $group
string $having
string $order
string $limit
Returns:
string

Definition at line 54 of file db.php.

DB_Base::error ( msg  ) 

Exit with an error message

Parameters:
string $msg

Definition at line 38 of file db.php.

Referenced by DB_SQLite3::_catch(), DB_SQLite::_catch(), DB_PostgreSQL::_catch(), DB_PDO::_catch(), DB_ODBC::_catch(), DB_MySQL::_catch(), DB_MSSQL::_catch(), and _catch().

& DB_Base::execute ( query_str,
query_arg = "",
bypass = false 
)

Execute the query, first calling Query() to finalize the query string

Parameters:
string $query_str Query string
array $query_arg Associative array of variables to substitute in
bool $bypass If set, bypass variable substitution
Returns:
mixed The result identifier

Definition at line 87 of file db.php.

References $fp, _catch(), and query().

Referenced by get_all(), get_all_pair(), get_item(), get_item_pair(), get_value(), get_values(), increment_row(), insert_all(), insert_row(), update_all(), and update_row().

& DB_Base::get_all ( query_str,
query_arg = "",
key = "" 
)

Return all rows from a query

Parameters:
string $query_str Query string
array $query_arg Query arguments
string $key If set, return only this column instead of the entire row
Returns:
mixed

Definition at line 162 of file db.php.

References $result, and execute().

& DB_Base::get_all_pair ( query_str,
query_arg = "" 
)

Return an associative array of key=>value pairs. The first item from the SELECT clause will be the key, and the second will be the value. If more than two items are in the SELECT, then everything after the first will be returned as a sub-array.

Parameters:
string $query_str Query string
array $query_arg Query arguments
Returns:
mixed

Definition at line 268 of file db.php.

References $result, and execute().

Referenced by DB_PDO::get_table_defn(), and DB_MySQL::get_table_defn().

& DB_Base::get_item ( query_str,
query_arg = "" 
)

Return a single row from a query string, false if not found

Parameters:
string $query_str Query string
array $query_arg Query arguments
Returns:
mixed

Definition at line 132 of file db.php.

References execute().

Referenced by get_item_by_pk(), increment_row(), and insert_update_row().

DB_Base::get_item_by_pk ( table,
pk,
pk_col = 'id' 
)

Return a single row from a query string using PK for lookup, false if not found

Parameters:
string $table
string $pk Value of ID/PK field
string $pk_col Name of PK column in this table
Returns:
mixed

Definition at line 150 of file db.php.

References get_item().

& DB_Base::get_item_pair ( query_str,
query_arg = "" 
)

Return an associative array of key=>value pairs. The first item from the SELECT clause will be the key, and the second will be the value. If more than two items are in the SELECT, then everything after the first will be returned as a sub-array.

Parameters:
string $query_str Query string
array $query_arg Query arguments
Returns:
mixed

Definition at line 238 of file db.php.

References execute().

& DB_Base::get_value ( query_str,
query_arg = "",
value = "" 
)

Return a single value from a query string, false if not found

Parameters:
string $query_str Query string
array $query_arg Query arguments
string $value If non-empty, use this value from the resulting row, otherwise use the first one
Returns:
mixed

Definition at line 185 of file db.php.

References execute().

& DB_Base::get_values ( query_str,
query_arg = "",
value = "" 
)

Return an array of value from a query string

Parameters:
string $query_str Query string
array $query_arg Query arguments
string $value If non-empty, use this value from the resulting row, otherwise use the first one
Returns:
array

Definition at line 212 of file db.php.

References $result, and execute().

DB_Base::increment_row ( sTable,
sField,
aKey 
)

Increment a column within a row specified by the key column(s). If the row does not exist, create it, setting the counter to 1. Useful for updating statistical counters.

Parameters:
string $sTable
string $sField Name of the column that will be incremented or inserted.
array $aKey Array of key/value pairs. If matching record is found, then $sField will be incremented by one. Otherwise, a row will be inserted and $sField will be set to one.

Definition at line 483 of file db.php.

References execute(), get_item(), and insert_row().

DB_Base::insert_all ( table,
data,
aFields = "",
mode = 'insert' 
)

Insert multiple records.

Parameters:
string $table
array $data
mixed $aFields

Definition at line 297 of file db.php.

References execute().

Referenced by replace_all().

DB_Base::insert_row ( sTable,
aRow,
mode = 'insert' 
)

Insert a record

Parameters:
string $sTable
array $aRow
string $mode Set to "replace" to use REPLACE INTO instead of INSERT INTO
Returns:
int Insert ID of new row

Definition at line 386 of file db.php.

References $mode, and execute().

Referenced by increment_row(), insert_update_row(), and replace_row().

DB_Base::insert_update_row ( sTable,
aRow,
aKey 
)

Insert or Update a record

Parameters:
string $sTable
array $aRow
array $aKey Array of key/value pairs. If matching record is found, then an update_row() is called, otherwise insert_row() is called.

Definition at line 456 of file db.php.

References get_item(), insert_row(), and update_row().

& DB_Base::query ( query_str,
query_arg = "",
bypass = false 
)

Generate a query string by substituting placeholders (eg, i) with their real values

Parameters:
string $query_str Query string
array $query_arg Associative array of variables to substitute in
bool $bypass If set, bypass variable substitution
Returns:
string The resulting SQL string

Definition at line 74 of file db.php.

Referenced by execute().

DB_Base::replace_all ( table,
data,
aFields = "" 
)

Replace multiple records.

Parameters:
string $table
array $data
mixed $aFields

Definition at line 333 of file db.php.

References insert_all().

DB_Base::replace_row ( sTable,
aRow 
)

Replace a record (REPLACE INTO)

Parameters:
string $sTable
array $aRow
Returns:
int Insert ID of new row

Definition at line 415 of file db.php.

References insert_row().

DB_Base::update_all ( table,
data,
where = "",
where_arg = "",
aUpdateFields = "" 
)

Update multiple records.

Parameters:
string $table
array $data
string $where
string $where_arg
mixed $aUpdateFields

Definition at line 346 of file db.php.

References execute().

DB_Base::update_row ( sTable,
aRow,
sWhere,
aWhereArgs = array() 
)

Update a record

Parameters:
string $sTable
array $aRow
string $sWhere WHERE clause to use for update
array $aWhereArgs Arguments to substitute into WHERE clause

Definition at line 427 of file db.php.

References execute().

Referenced by insert_update_row().


Member Data Documentation

DB_Base::$conn
DB_Base::$debug = false

Definition at line 20 of file db.php.

DB_Base::$echo = false

Definition at line 19 of file db.php.

DB_Base::$error

Definition at line 17 of file db.php.

DB_Base::$insert_id

Definition at line 18 of file db.php.

DB_Base::$profile = false

Definition at line 21 of file db.php.

DB_Base::$profile_data = array()

Definition at line 22 of file db.php.

DB_Base::$query

Definition at line 15 of file db.php.

DB_Base::$result

Definition at line 16 of file db.php.

Referenced by get_all(), get_all_pair(), and get_values().


The documentation for this class was generated from the following file:

Generated on Wed Jan 13 09:21:04 2010 for Pronto Framework by  doxygen 1.6.1