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(), $class_name= '\Habari\QueryRecord') |
static | get_row ($query, $args=array(), $class_name= '\Habari\QueryRecord') |
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 15 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 169 of file db.php.
Referenced by WPImport::action_auth_ajax_wp_import_comments(), WPImport::action_auth_ajax_wp_import_posts(), WPImport::action_auth_ajax_wp_import_users(), Vocabulary::add_term(), and Vocabulary::move_term().
static DB::clear_errors | ( | ) | [static] |
static DB::commit | ( | ) | [static] |
Commit a currently running transaction
Definition at line 187 of file db.php.
Referenced by WPImport::action_auth_ajax_wp_import_comments(), WPImport::action_auth_ajax_wp_import_posts(), WPImport::action_auth_ajax_wp_import_users(), 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 43 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.
array | $queries array of create table and insert statements which constitute a fresh install | |
bool | $execute (optional) should the queries be executed against the database or just simulated. default = true | |
bool | $silent (optional) silent running with no messages printed? default = true | |
bool | $doinserts |
Definition at line 395 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 Table to delete from | |
array | $keyfields Associative array of field values to match |
DB::delete( 'mytable', array( 'fieldname' => 'value' ) );
Definition at line 357 of file db.php.
Referenced by InfoRecords::__unset(), AdminDashboardHandler::ajax_dashboard(), ACL::revoke_group_token(), ACL::revoke_user_token(), and EventLog::unregister_type().
static DB::exec | ( | $ | query | ) | [static] |
Execute the given query on the database. Encapsulates PDO::exec. WARNING: Make sure you don't call this with a SELECT statement. PDO will buffer the results and leave your cursor dangling.
string | $query the query to run |
Definition at line 135 of file db.php.
Referenced by Comment::remove_status(), and Comment::remove_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 Table to check | |
array | $keyfieldvalues Associative array of field values to match |
DB::exists( 'mytable', array( 'fieldname' => 'value' ) );
Definition at line 330 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 | $query The query to execute | |
array | $args Arguments to pass for prepared statements |
$ary = DB::get_column( 'SELECT col1 FROM tablename WHERE foo = ?', array('fieldvalue') );
Definition at line 281 of file db.php.
Referenced by WPImport::action_auth_ajax_wp_import_comments(), WPImport::action_auth_ajax_wp_import_posts(), Query::column(), Vocabulary::delete(), Post::get_tokens(), ACL::grant_group(), UserGroup::load_member_cache(), Term::objects(), and ACL::user_tokens().
static DB::get_driver_name | ( | ) | [static] |
Definition at line 430 of file db.php.
Referenced by Theme::filter_provided(), Pluggable::get_db_schema(), and AdminHandler::get_sysinfo().
static DB::get_driver_version | ( | ) | [static] |
static DB::get_errors | ( | ) | [static] |
Returns error data gathered from database connection
Definition at line 216 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 | $query The query to execute | |
array | $args Arguments to pass for prepared statements |
$ary= DB::get_keyvalue( 'SELECT keyfield, valuefield FROM tablename');
Definition at line 306 of file db.php.
Referenced by Query::keyvalue(), Comment::list_comment_statuses(), Comment::list_comment_types(), and Post::list_revisions().
static DB::get_last_error | ( | ) | [static] |
Returns only the last error info
Definition at line 242 of file db.php.
Referenced by AdminUsersHandler::do_add_user().
static DB::get_profiles | ( | ) | [static] |
Returns query profiles
Definition at line 197 of file db.php.
Referenced by Theme::theme_query_count(), and Theme::theme_query_time().
static DB::get_results | ( | $ | query, | |
$ | args = array() , |
|||
$ | class_name = '\Habari\QueryRecord' | |||
) | [static] |
Execute a query and return the results as an array of objects
string | $query the query to execute | |
array | $args array of arguments to pass for prepared statements | |
null|string | $class_name The name of the class name to return results as |
$ary = DB::get_results( 'SELECT * FROM tablename WHERE foo = ?', array('fieldvalue'), 'extendedQueryRecord' );
Definition at line 255 of file db.php.
Referenced by UserGroup::__get(), InfoRecords::_load(), CronHandler::act_poll_cron(), WPImport::action_auth_ajax_wp_import_comments(), WPImport::action_auth_ajax_wp_import_posts(), CoreDashModules::action_block_content_latest_comments(), Menus::action_plugin_deactivation(), AdminThemesHandler::ajax_add_block(), AdminThemesHandler::ajax_save_areas(), ACL::all_tokens(), Term::ancestors(), Term::children(), Term::descendants(), RewriteRules::get_active(), Options::get_all_options(), Theme::get_blocks(), Tags::get_by_frequency(), Post::get_revision_data(), Vocabulary::get_root_terms(), Theme::get_scopes(), Vocabulary::get_search(), AdminThemesHandler::get_themes(), Post::list_active_post_types(), Post::list_all_post_types(), LogEntry::list_logentry_types(), Post::list_post_statuses(), UserGroup::load_permissions_cache(), Term::not_ancestors(), Term::not_descendants(), Term::object_types(), AdminThemesHandler::prepare_block_list(), Query::results(), CronHandler::run_cron(), Vocabulary::search_term(), Charcoal::theme_show_tags(), and ACL::user_tokens().
static DB::get_row | ( | $ | query, | |
$ | args = array() , |
|||
$ | class_name = '\Habari\QueryRecord' | |||
) | [static] |
Returns a single row (the first in a multi-result set) object for a query
string | $query The query to execute | |
array | $args Arguments to pass for prepared statements | |
string | $class_name Optional class name for row result object |
$obj = DB::get_row( 'SELECT * FROM tablename WHERE foo = ?', array('fieldvalue'), 'extendedQueryRecord' );
Definition at line 268 of file db.php.
Referenced by AdminDashboardHandler::ajax_dashboard(), AdminThemesHandler::ajax_delete_block(), Term::get(), Comment::get(), UserGroup::get_by_id(), UserGroup::get_by_name(), CronTab::get_cronjob(), Vocabulary::get_term(), Term::parent(), Session::read(), Query::row(), and Term::setslug().
static DB::get_value | ( | $ | query, | |
$ | args = array() | |||
) | [static] |
Return a single value from the database
string | $query the query to execute | |
array | $args Arguments to pass for prepared statements |
Definition at line 293 of file db.php.
Referenced by CronHandler::act_poll_cron(), SpamChecker::action_comment_insert_before(), CronTab::add_cron(), Vocabulary::add_term(), Block::add_to_area(), AdminDashboardHandler::ajax_dashboard(), UserGroup::create(), ACL::destroy_token(), AdminDashboardHandler::get_dashboard(), LogEntry::get_event_module(), LogEntry::get_event_type(), ACL::get_group_token_access(), ACL::grant_user(), UserGroup::id(), UserGroup::insert(), Vocabulary::max_count(), Vocabulary::move_term(), UserGroup::name(), Term::object_count(), Vocabulary::object_type_id(), CronHandler::run_cron(), Theme::theme_area(), ACL::token_description(), ACL::token_exists(), EventLog::unregister_type(), Posts::update_scheduled_posts_cronjob(), and Query::value().
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 | $table The table name | |
array | $fieldvalues An associative array of fields and values to insert |
DB::insert( 'mytable', array( 'fieldname' => 'value' ) );
Definition at line 318 of file db.php.
Referenced by QueryRecord::insertRecord().
static DB::instance | ( | ) | [static, protected] |
Enables singleton working properly
Reimplemented from Singleton.
Definition at line 28 of file db.php.
Referenced by begin_transaction(), clear_errors(), commit(), connect(), dbdelta(), delete(), exec(), execute_procedure(), exists(), get_column(), get_driver_name(), get_driver_version(), 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(), upgrade(), upgrade_post(), and upgrade_pre().
static DB::is_connected | ( | ) | [static] |
Check whether there is an existing connection to a database.
Definition at line 458 of file db.php.
Referenced by Error::error_handler(), Options::get_all_options(), and 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 371 of file db.php.
Referenced by Comment::add_status(), Comment::add_type(), Vocabulary::insert(), UserGroup::insert(), Term::insert(), Post::insert(), LogEntry::insert(), Block::insert(), User::insert(), Comment::insert(), and QueryRecord::insertRecord().
static DB::list_tables | ( | ) | [static] |
static DB::query | ( | $ | query, | |
$ | args = array() | |||
) | [static] |
Queries the database for a given SQL command.
string | $query the SQL query text | |
array | $args array of values to use for placeholder replacement |
Definition at line 146 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(), AdminDashboardHandler::ajax_dashboard(), 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(), Post::delete_post_status(), Vocabulary::delete_term(), Session::destroy(), ACL::destroy_token(), Term::dissociate(), Session::gc(), Vocabulary::move_term(), Vocabulary::prep_update(), 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 179 of file db.php.
Referenced by WPImport::action_auth_ajax_wp_import_comments(), WPImport::action_auth_ajax_wp_import_posts(), WPImport::action_auth_ajax_wp_import_users(), 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
string | $class_name Name of class to create during fetch |
Definition at line 122 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
integer | $mode One of the PDO::FETCH_MODE integers |
Definition at line 112 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
string | $name table name of the table |
Definition at line 90 of file db.php.
Referenced by Options::__set(), Options::__unset(), Locale::_t(), SpamChecker::action_comment_insert_before(), Comment::add_status(), Comment::add_type(), UserGroup::delete(), RewriteRule::delete(), LogEntry::delete(), CronJob::delete(), User::delete(), Comment::delete(), QueryRecord::deleteRecord(), Vocabulary::insert(), UserGroup::insert(), Term::insert(), RewriteRule::insert(), LogEntry::insert(), CronJob::insert(), Block::insert(), User::insert(), Comment::insert(), QueryRecord::insertRecord(), Comment::remove_status(), Comment::remove_type(), RewriteRule::update(), CronJob::update(), Block::update(), User::update(), Comment::update(), QueryRecord::updateRecord(), 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 Table to update | |
array | $fieldvalues Associative array of field values to set | |
array | $keyfields Associative array of field values to match |
DB::update( 'mytable', array( 'fieldname' => 'newvalue' ), array( 'fieldname' => 'value' ) );
Definition at line 345 of file db.php.
Referenced by Options::__set(), InfoRecords::commit(), ACL::grant_group(), ACL::grant_user(), QueryRecord::updateRecord(), and Session::write().
static DB::upgrade | ( | $ | old_version | ) | [static] |
static DB::upgrade_post | ( | $ | old_version | ) | [static] |
$old_version |
Definition at line 422 of file db.php.
Referenced by InstallHandler::upgrade_db().
static DB::upgrade_pre | ( | $ | old_version | ) | [static] |
$old_version |
Definition at line 414 of file db.php.
Referenced by InstallHandler::upgrade_db().