Inheritance diagram for DB:
Collaboration diagram for DB:Static Public Member Functions | |
| static | connect () |
| static | disconnect () |
| static | table ($name) |
| static | register_table ($name) |
| static | set_fetch_mode ($mode) |
| static | set_fetch_class ($class_name) |
| static | exec ($query) |
| static | query ($query, $args=array()) |
| static | execute_procedure ($procedure, $args=array()) |
| static | begin_transaction () |
| static | rollback () |
| static | commit () |
| static | get_profiles () |
| static | get_errors () |
| static | has_errors () |
| static | clear_errors () |
| static | get_last_error () |
| static | get_results ($query, $args=array()) |
| static | get_row ($query, $args=array()) |
| static | get_column ($query, $args=array()) |
| static | get_value ($query, $args=array()) |
| static | get_keyvalue ($query, $args=array()) |
| static | insert ($table, $fieldvalues) |
| static | exists ($table, $keyfieldvalues) |
| static | update ($table, $fieldvalues, $keyfields) |
| static | delete ($table, $keyfields) |
| static | last_insert_id () |
| static | row_count () |
| static | dbdelta ($queries, $execute=true, $silent=true, $doinserts=false) |
| static | upgrade ($old_version) |
| static | upgrade_pre ($old_version) |
| static | upgrade_post ($old_version) |
| static | get_driver_name () |
| static | get_driver_version () |
| static | list_tables () |
| static | is_connected () |
| static | in_transaction () |
| static | quote ($string) |
Static Protected Member Functions | |
| static | instance () |
Singleton class for database connection and manipulation
Definition at line 13 of file db.php.
| static DB::begin_transaction | ( | ) | [static] |
Start a transaction against the RDBMS in order to wrap multiple statements in a safe ACID-compliant container
Definition at line 155 of file db.php.
Referenced by Vocabulary::add_term(), and Vocabulary::move_term().
| static DB::clear_errors | ( | ) | [static] |
| static DB::commit | ( | ) | [static] |
Commit a currently running transaction
Definition at line 173 of file db.php.
Referenced by Vocabulary::add_term(), and Vocabulary::move_term().
| static DB::connect | ( | ) | [static] |
Connects to the database server. If no arguments are supplied, then the connection is attempted for the database authentication variables in config.php.
| (optional) | connection_string a PDO connection string | |
| (optional) | db_user the database user name | |
| (optional) | db_pass the database user password |
Definition at line 37 of file db.php.
Referenced by InstallHandler::ajax_check_mysql_credentials(), InstallHandler::ajax_check_pgsql_credentials(), InstallHandler::ajax_check_sqlite_credentials(), InstallHandler::check_mysql(), and InstallHandler::check_pgsql().
| static DB::dbdelta | ( | $ | queries, | |
| $ | execute = true, |
|||
| $ | silent = true, |
|||
| $ | doinserts = false | |||
| ) | [static] |
Automatic database diffing function, used for determining required database upgrades.
| queries | array of create table and insert statements which constitute a fresh install | |
| (optional) | execute should the queries be executed against the database or just simulated. default = true | |
| (optional) | silent silent running with no messages printed? default = true |
Definition at line 392 of file db.php.
Referenced by InstallHandler::upgrade_db().
| static DB::delete | ( | $ | table, | |
| $ | keyfields | |||
| ) | [static] |
Deletes any record that matches the specific criteria
| string | Table to delete from | |
| array | Associative array of field values to match |
DB::delete( 'mytable', array( 'fieldname' => 'value' ) ); Definition at line 355 of file db.php.
Referenced by InfoRecords::__unset(), ACL::revoke_group_token(), ACL::revoke_user_token(), and EventLog::unregister_type().
| static DB::execute_procedure | ( | $ | procedure, | |
| $ | args = array() | |||
| ) | [static] |
| static DB::exists | ( | $ | table, | |
| $ | keyfieldvalues | |||
| ) | [static] |
Checks for a record that matches the specific criteria
| string | Table to check | |
| array | Associative array of field values to match |
DB::exists( 'mytable', array( 'fieldname' => 'value' ) ); Definition at line 328 of file db.php.
Referenced by Vocabulary::add_object_type(), Term::associate(), Post::delete_post_type(), and EventLog::unregister_type().
| static DB::get_column | ( | $ | query, | |
| $ | args = array() | |||
| ) | [static] |
Returns all values for a column for a query
| string | The query to execute | |
| array | Arguments to pass for prepared statements |
$ary = DB::get_column( 'SELECT col1 FROM tablename WHERE foo = ?', array('fieldvalue') ); Definition at line 279 of file db.php.
Referenced by Vocabulary::delete(), Post::get_tokens(), ACL::grant_group(), UserGroup::load_member_cache(), Term::objects(), and ACL::user_tokens().
| static DB::get_errors | ( | ) | [static] |
Returns error data gathered from database connection
Definition at line 202 of file db.php.
Referenced by Term::setslug().
| static DB::get_keyvalue | ( | $ | query, | |
| $ | args = array() | |||
| ) | [static] |
Returns an associative array using the first returned column as the array key and the second as the array value
| string | The query to execute | |
| array | Arguments to pass for prepared statements |
$ary= DB::get_keyvalue( 'SELECT keyfield, valuefield FROM tablename'); Definition at line 304 of file db.php.
Referenced by Term::object_types().
| static DB::get_last_error | ( | ) | [static] |
Returns only the last error info
Definition at line 228 of file db.php.
Referenced by AdminUsersHandler::post_users().
| static DB::get_profiles | ( | ) | [static] |
Returns query profiles
Definition at line 183 of file db.php.
Referenced by Theme::theme_query_count(), and Theme::theme_query_time().
| static DB::get_results | ( | $ | query, | |
| $ | args = array() | |||
| ) | [static] |
Execute a query and return the results as an array of objects
| query | the query to execute | |
| args | array of arguments to pass for prepared statements | |
| string | Optional class name for row result objects |
$ary = DB::get_results( 'SELECT * FROM tablename WHERE foo = ?', array('fieldvalue'), 'extendedQueryRecord' ); Definition at line 241 of file db.php.
Referenced by UserGroup::__get(), InfoRecords::_load(), CronTab::act_poll_cron(), AdminThemesHandler::ajax_add_block(), AdminThemesHandler::ajax_delete_block(), AdminThemesHandler::ajax_save_areas(), ACL::all_tokens(), Term::ancestors(), Term::children(), Term::descendants(), CoreDashModules::filter_dash_module_latest_comments(), RewriteRules::get_active(), Vocabulary::get_all(), Vocabulary::get_all_object_terms(), Options::get_all_options(), Theme::get_blocks(), Tags::get_by_frequency(), Vocabulary::get_object_terms(), Vocabulary::get_root_terms(), Theme::get_scopes(), AdminThemesHandler::get_themes(), Vocabulary::get_tree(), Post::list_active_post_types(), Post::list_all_post_types(), LogEntry::list_logentry_types(), Post::list_post_statuses(), UserGroup::load_permissions_cache(), Vocabulary::names(), Term::not_ancestors(), Term::not_descendants(), Posts::publish_scheduled_posts(), CronTab::run_cron(), Charcoal::theme_show_tags(), and ACL::user_tokens().
| static DB::get_row | ( | $ | query, | |
| $ | args = array() | |||
| ) | [static] |
Returns a single row (the first in a multi-result set) object for a query
| string | The query to execute | |
| array | Arguments to pass for prepared statements | |
| string | Optional class name for row result object |
$obj = DB::get_row( 'SELECT * FROM tablename WHERE foo = ?', array('fieldvalue'), 'extendedQueryRecord' ); Definition at line 260 of file db.php.
Referenced by AdminThemesHandler::ajax_delete_block(), CoreDashModules::filter_dash_module_latest_comments(), Vocabulary::get(), Term::get(), Comment::get(), Vocabulary::get_by_id(), UserGroup::get_by_id(), UserGroup::get_by_name(), AdminThemesHandler::get_configure_block(), CronTab::get_cronjob(), Vocabulary::get_term(), Term::parent(), Session::read(), and Term::setslug().
| static DB::get_value | ( | $ | query, | |
| $ | args = array() | |||
| ) | [static] |
Return a single value from the database
| string | the query to execute | |
| array | Arguments to pass for prepared statements |
Definition at line 291 of file db.php.
Referenced by CronTab::act_poll_cron(), SpamChecker::action_comment_insert_before(), CronTab::add_cron(), Vocabulary::add_term(), Block::add_to_area(), UserGroup::create(), ACL::destroy_token(), Vocabulary::exists(), AdminDashboardHandler::get_dashboard(), LogEntry::get_event_module(), LogEntry::get_event_type(), ACL::get_group_token_access(), ACL::grant_user(), UserGroup::id(), UserGroup::insert(), Vocabulary::is_empty(), Vocabulary::max_count(), Vocabulary::move_term(), UserGroup::name(), Term::object_count(), Vocabulary::object_type_id(), CronTab::run_cron(), Theme::theme_area(), ACL::token_description(), ACL::token_exists(), EventLog::unregister_type(), and Posts::update_scheduled_posts_cronjob().
| static DB::has_errors | ( | ) | [static] |
Determines if there have been errors since the last clear_errors() call
| static DB::in_transaction | ( | ) | [static] |
| static DB::insert | ( | $ | table, | |
| $ | fieldvalues | |||
| ) | [static] |
Inserts into the specified table values associated to the key fields
| string | The table name | |
| array | An associative array of fields and values to insert |
DB::insert( 'mytable', array( 'fieldname' => 'value' ) ); | static DB::instance | ( | ) | [static, protected] |
Enables singleton working properly
Reimplemented from Singleton.
Definition at line 22 of file db.php.
Referenced by begin_transaction(), clear_errors(), commit(), connect(), dbdelta(), delete(), execute_procedure(), exists(), get_column(), get_errors(), get_keyvalue(), get_last_error(), get_profiles(), get_results(), get_row(), get_value(), has_errors(), in_transaction(), insert(), is_connected(), last_insert_id(), list_tables(), query(), quote(), register_table(), rollback(), row_count(), set_fetch_class(), set_fetch_mode(), table(), update(), and upgrade().
| static DB::is_connected | ( | ) | [static] |
Check whether there is an existing connection to a database.
Definition at line 442 of file db.php.
Referenced by Pluggable::upgrade().
| static DB::last_insert_id | ( | ) | [static] |
Helper function to return the last inserted sequence or auto_increment field. Useful when doing multiple inserts within a single transaction -- for example, adding dependent related rows.
Definition at line 369 of file db.php.
Referenced by Vocabulary::insert(), UserGroup::insert(), Term::insert(), Post::insert(), LogEntry::insert(), Block::insert(), User::insert(), and Comment::insert().
| static DB::list_tables | ( | ) | [static] |
| static DB::query | ( | $ | query, | |
| $ | args = array() | |||
| ) | [static] |
Queries the database for a given SQL command.
| query | the SQL query text | |
| args | array of values to use for placeholder replacement | |
| class_name | (optional) name of class name to wrangle returned data to |
Definition at line 132 of file db.php.
Referenced by Post::activate_post_type(), Post::add_new_status(), Post::add_new_type(), Vocabulary::add_term(), Block::add_to_area(), AdminThemesHandler::ajax_save_areas(), Session::clear_userid(), ACL::create_token(), Post::deactivate_post_type(), Vocabulary::delete(), UserGroup::delete(), Term::delete(), User::delete(), InfoRecords::delete_all(), Comments::delete_by_status(), Vocabulary::delete_term(), Session::destroy(), ACL::destroy_token(), Term::dissociate(), Session::gc(), Vocabulary::move_term(), Vocabulary::prep_update(), Session::read(), Posts::reassign(), ACL::rebuild_permissions(), EventLog::register_type(), UserGroup::set_member_list(), and Session::set_userid().
| static DB::quote | ( | $ | string | ) | [static] |
| static DB::register_table | ( | $ | name | ) | [static] |
| static DB::rollback | ( | ) | [static] |
Rolls a currently running transaction back to the prexisting state, or, if the RDBMS supports it, whenever a savepoint was committed.
Definition at line 165 of file db.php.
Referenced by Vocabulary::add_term(), and Vocabulary::move_term().
| static DB::row_count | ( | ) | [static] |
| static DB::set_fetch_class | ( | $ | class_name | ) | [static] |
Sets the class to fetch, if fetch mode is PDO::FETCH_CLASS
| class_name | Name of class to create during fetch |
Definition at line 115 of file db.php.
Referenced by EventLog::get(), Users::get(), Posts::get(), and Comments::get().
| static DB::set_fetch_mode | ( | $ | mode | ) | [static] |
Sets the fetch mode for return calls from PDOStatement
| mode | One of the PDO::FETCH_MODE integers |
Definition at line 105 of file db.php.
Referenced by UserGroups::get(), EventLog::get(), Users::get(), Posts::get(), and Comments::get().
| static DB::table | ( | $ | name | ) | [static] |
Helper function to naturally return table names
| table | name of the table |
Definition at line 83 of file db.php.
Referenced by Options::__set(), Options::__unset(), SpamChecker::action_comment_insert_before(), UserGroup::delete(), RewriteRule::delete(), Post::delete(), LogEntry::delete(), CronJob::delete(), User::delete(), Comment::delete(), Vocabulary::insert(), UserGroup::insert(), Term::insert(), RewriteRule::insert(), Post::insert(), LogEntry::insert(), CronJob::insert(), Block::insert(), User::insert(), Comment::insert(), Comments::moderate_these(), RewriteRule::update(), Post::update(), CronJob::update(), Block::update(), User::update(), Comment::update(), and Session::write().
| static DB::update | ( | $ | table, | |
| $ | fieldvalues, | |||
| $ | keyfields | |||
| ) | [static] |
function update Updates any record that matches the specific criteria A new row is inserted if no existing record matches the criteria
| string | Table to update | |
| array | Associative array of field values to set | |
| array | Associative array of field values to match |
DB::update( 'mytable', array( 'fieldname' => 'newvalue' ), array( 'fieldname' => 'value' ) ); Definition at line 343 of file db.php.
Referenced by Options::__set(), InfoRecords::commit(), ACL::grant_group(), ACL::grant_user(), Comments::moderate_these(), and Session::write().
| static DB::upgrade | ( | $ | old_version | ) | [static] |
1.7.1