Inherited by DB_MSSQL, DB_MySQL, DB_ODBC, DB_PDO, DB_PostgreSQL, DB_SQLite, and DB_SQLite3.
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() | |
PRONTO WEB FRAMEWORK Copyright (C) 2006, Judd Vinet
Description: DB interface, used by models and page controllers.
Definition at line 12 of file db.php.
| DB_Base::_catch | ( | $ | msg = "" |
) |
| DB_Base::build_sql | ( | $ | select, | |
| $ | from, | |||
| $ | where = '', |
|||
| $ | group = '', |
|||
| $ | having = '', |
|||
| $ | order = '', |
|||
| $ | limit = '' | |||
| ) |
| DB_Base::error | ( | $ | msg | ) |
Exit with an error message
| 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
| string | $query_str Query string | |
| array | $query_arg Associative array of variables to substitute in | |
| bool | $bypass If set, bypass variable substitution |
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 = "" | |||
| ) |
| & 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.
| string | $query_str Query string | |
| array | $query_arg Query arguments |
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
| string | $query_str Query string | |
| array | $query_arg Query arguments |
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
| string | $table | |
| string | $pk Value of ID/PK field | |
| string | $pk_col Name of PK column in this table |
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.
| string | $query_str Query string | |
| array | $query_arg Query arguments |
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
| 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 |
Definition at line 185 of file db.php.
References execute().
| & DB_Base::get_values | ( | $ | query_str, | |
| $ | query_arg = "", |
|||
| $ | value = "" | |||
| ) |
| 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.
| 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.
| 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
| string | $sTable | |
| array | $aRow | |
| string | $mode Set to "replace" to use REPLACE INTO instead of INSERT INTO |
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
| 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
| string | $query_str Query string | |
| array | $query_arg Associative array of variables to substitute in | |
| bool | $bypass If set, bypass variable substitution |
Definition at line 74 of file db.php.
Referenced by execute().
| DB_Base::replace_all | ( | $ | table, | |
| $ | data, | |||
| $ | aFields = "" | |||
| ) |
Replace multiple records.
| 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)
| string | $sTable | |
| array | $aRow |
Definition at line 415 of file db.php.
References insert_row().
| DB_Base::update_all | ( | $ | table, | |
| $ | data, | |||
| $ | where = "", |
|||
| $ | where_arg = "", |
|||
| $ | aUpdateFields = "" | |||
| ) |
| DB_Base::update_row | ( | $ | sTable, | |
| $ | aRow, | |||
| $ | sWhere, | |||
| $ | aWhereArgs = array() | |||
| ) |
Update a record
| 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().
| DB_Base::$conn |
Definition at line 14 of file db.php.
Referenced by DB_MSSQL::DB_MSSQL(), DB_MySQL::DB_MySQL(), DB_ODBC::DB_ODBC(), DB_PDO::DB_PDO(), DB_PostgreSQL::DB_PostgreSQL(), DB_SQLite::DB_SQLite(), and DB_SQLite3::DB_SQLite3().
| DB_Base::$result |
Definition at line 16 of file db.php.
Referenced by get_all(), get_all_pair(), and get_values().
1.6.1