Go to the source code of this file.
Packages | |
| package | Elgg |
Elgg CSS file. | |
Functions | |
| establish_db_link ($dblinkname="readwrite") | |
| Connect to the database server and use the Elgg database for a particular database link. | |
| setup_db_connections () | |
| Establish all database connections. | |
| db_profiling_shutdown_hook () | |
| Shutdown hook to display profiling information about db (debug mode). | |
| db_delayedexecution_shutdown_hook () | |
| Execute any delayed queries. | |
| init_db ($event, $object_type, $object=null) | |
| Alias to setup_db_connections, for use in the event handler. | |
| get_db_link ($dblinktype) | |
| Gets the appropriate db link for the operation mode requested. | |
| explain_query ($query, $link) | |
| Explain a given query, useful for debug. | |
| execute_query ($query, $dblink) | |
| Execute a query. | |
| execute_delayed_query ($query, $dblink, $handler="") | |
| Queue a query for execution after all output has been sent to the user. | |
| execute_delayed_write_query ($query, $handler="") | |
| Write wrapper for execute_delayed_query(). | |
| execute_delayed_read_query ($query, $handler="") | |
| Read wrapper for execute_delayed_query(). | |
| get_data ($query, $callback="") | |
| Use this function to get data from the database. | |
| get_data_row ($query, $callback="") | |
| Use this function to get a single data row from the database. | |
| insert_data ($query) | |
| Use this function to insert database data; returns id or false. | |
| update_data ($query) | |
| Update database data. | |
| delete_data ($query) | |
| Use this function to delete data. | |
| get_db_tables () | |
| Get the tables currently installed in the Elgg database. | |
| optimize_table ($table) | |
| Run an optimize query on a mysql tables. | |
| get_db_error ($dblink) | |
| Get the last database error for a particular database link. | |
| run_sql_script ($scriptlocation) | |
| Runs a full database script from disk. | |
| db_upgrade ($version, $fromdir="", $quiet=FALSE) | |
| Upgrade the database schema in an ordered sequence. | |
| db_check_version () | |
| This function, called by validate_platform(), will check whether the installed version of MySQL meets the minimum required. | |
| sanitise_string_special ($string, $extra_escapeable= '') | |
| Sanitise a string for database use, but with the option of escaping extra characters. | |
| sanitise_string ($string) | |
| Sanitise a string for database use. | |
| sanitize_string ($string) | |
| Wrapper function for alternate English spelling. | |
| sanitise_int ($int) | |
| Sanitises an integer for database use. | |
| sanitize_int ($int) | |
| Wrapper function for alternate English spelling. | |
Variables | |
| $DB_QUERY_CACHE = array() | |
| $DB_DELAYED_QUERIES = array() | |
| db_check_version | ( | ) |
This function, called by validate_platform(), will check whether the installed version of MySQL meets the minimum required.
Definition at line 585 of file database.php.
References $version.
Referenced by validate_platform().
| db_delayedexecution_shutdown_hook | ( | ) |
Execute any delayed queries.
Definition at line 108 of file database.php.
References $CONFIG, $DB_DELAYED_QUERIES, $e, $result, elgg_log(), and execute_query().
| db_profiling_shutdown_hook | ( | ) |
Shutdown hook to display profiling information about db (debug mode).
Definition at line 98 of file database.php.
References elgg_log().
| db_upgrade | ( | $ | version, | |
| $ | fromdir = "", |
|||
| $ | quiet = FALSE | |||
| ) |
Upgrade the database schema in an ordered sequence.
Makes use of schema upgrade files
This is a about as core as it comes, so don't start running this from your plugins!
| int | $version The version you are upgrading from (usually given in the Elgg version format of YYYYMMDDXX - see version.php for example) | |
| string | $fromdir Optional directory to load upgrades from (default: engine/schema/upgrades/) | |
| bool | $quiet If true, will suppress all error messages. Don't use this. |
Definition at line 526 of file database.php.
References $CONFIG, $e, $version, is_db_installed(), is_installed(), and run_sql_script().
Referenced by version_upgrade().
| delete_data | ( | $ | query | ) |
Use this function to delete data.
| mixed | $query The SQL query to run |
Definition at line 403 of file database.php.
References $CONFIG, $DB_QUERY_CACHE, elgg_log(), execute_query(), and get_db_link().
Referenced by ElggCoreEntityGetterFunctionsTest.__destruct(), ElggHMACCache.__destruct(), __elgg_session_destroy(), __elgg_session_gc(), archive_log(), clear_annotations(), clear_metadata(), ElggHMACCache.delete(), delete_access_collection(), delete_annotation(), delete_entity(), delete_metadata(), delete_orphaned_metastrings(), delete_relationship(), entities_gc(), remove_all_private_settings(), remove_api_user(), remove_entity_relationship(), remove_entity_relationships(), remove_expired_user_tokens(), remove_from_river_by_annotation(), remove_from_river_by_id(), remove_from_river_by_object(), remove_from_river_by_subject(), remove_private_setting(), remove_user_from_access_collection(), remove_user_token(), ElggCoreEntityGetterFunctionsTest.testElggApiGettersEntityNoValueSubtypeSet(), and unset_config().
| establish_db_link | ( | $ | dblinkname = "readwrite" |
) |
Connect to the database server and use the Elgg database for a particular database link.
| string | $dblinkname Default "readwrite"; you can change this to set up additional global database links, eg "read" and "write" |
Definition at line 22 of file database.php.
References $CONFIG, $DB_QUERY_CACHE, $dbhost, $dbname, $dbuser, and elgg_echo().
Referenced by setup_db_connections().
| execute_delayed_query | ( | $ | query, | |
| $ | dblink, | |||
| $ | handler = "" | |||
| ) |
Queue a query for execution after all output has been sent to the user.
You can specify a handler function if you care about the result. This function will accept the raw result from mysql_query();
| string | $query The query to execute | |
| resource | $dblink The database link to use | |
| string | $handler The handler |
Definition at line 204 of file database.php.
References $DB_DELAYED_QUERIES, $handler, and $query.
Referenced by execute_delayed_read_query(), and execute_delayed_write_query().
| execute_delayed_read_query | ( | $ | query, | |
| $ | handler = "" | |||
| ) |
Read wrapper for execute_delayed_query().
| string | $query The query to execute | |
| string | $handler The handler if you care about the result. |
Definition at line 238 of file database.php.
References $handler, $query, execute_delayed_query(), and get_db_link().
| execute_delayed_write_query | ( | $ | query, | |
| $ | handler = "" | |||
| ) |
Write wrapper for execute_delayed_query().
| string | $query The query to execute | |
| string | $handler The handler if you care about the result. |
Definition at line 228 of file database.php.
References $handler, $query, execute_delayed_query(), and get_db_link().
Referenced by elgg_geocode_location().
| execute_query | ( | $ | query, | |
| $ | dblink | |||
| ) |
Execute a query.
| string | $query The query | |
| link | $dblink the DB link |
Definition at line 177 of file database.php.
References $CONFIG, $DB_QUERY_CACHE, $query, and $result.
Referenced by db_delayedexecution_shutdown_hook(), delete_data(), explain_query(), get_data(), get_data_row(), insert_data(), and update_data().
| explain_query | ( | $ | query, | |
| $ | link | |||
| ) |
Explain a given query, useful for debug.
Definition at line 162 of file database.php.
References $link, $query, $result, and execute_query().
| get_data | ( | $ | query, | |
| $ | callback = "" | |||
| ) |
Use this function to get data from the database.
| mixed | $query The query being passed. | |
| string | $call Optionally, the name of a function to call back to on each row (which takes $row as a single parameter) |
Definition at line 248 of file database.php.
References $callback, $CONFIG, $DB_QUERY_CACHE, $query, $result, elgg_log(), execute_query(), and get_db_link().
Referenced by __get_entities_from_annotations_calculate_x(), clear_annotations_by_owner(), clear_metadata_by_owner(), datalist_get(), delete_entity(), delete_orphaned_metastrings(), disable_entity(), elgg_get_entities(), elgg_get_tags(), elgg_is_admin_user(), find_active_users(), find_metadata(), get_access_array(), get_activity_stream_data(), get_all_config(), get_all_private_settings(), get_annotations(), get_db_tables(), get_entities_by_relationship_count(), get_entities_from_metadata_groups(), get_entities_from_metadata_groups_multi(), get_entities_from_private_setting(), get_entities_from_private_setting_multi(), get_entities_in_area(), get_entity_dates(), get_entity_relationships(), get_entity_statistics(), get_members_of_access_collection(), get_metadata_byname(), get_metadata_for_entity(), get_metastring_id(), get_notable_entities(), get_notable_entities_from_metadata(), get_noteable_entities_from_relationship(), get_objects_in_group(), get_river_items(), get_system_log(), get_user_access_collections(), get_user_by_email(), get_user_tokens(), get_write_access_array(), has_access_to_entity(), input_livesearch_page_handler(), remove_metadata(), search_comments_hook(), search_for_group(), search_for_object(), search_for_site(), and search_for_user().
| get_data_row | ( | $ | query, | |
| $ | callback = "" | |||
| ) |
Use this function to get a single data row from the database.
| mixed | $query The query to run. |
Definition at line 302 of file database.php.
References $callback, $CONFIG, $DB_QUERY_CACHE, $query, $result, elgg_log(), execute_query(), and get_db_link().
Referenced by __elgg_session_read(), __get_annotations_calculate_x(), __get_entities_from_annotations_calculate_x(), check_entity_relationship(), create_group_entity(), create_metadata(), create_object_entity(), create_site_entity(), create_user_entity(), elgg_geocode_location(), elgg_get_entities(), ElggCoreUserTest.fetchUser(), get_access_collection(), get_annotation(), get_api_user(), get_config(), get_entities_by_relationship_count(), get_entities_from_metadata_groups(), get_entities_from_metadata_groups_multi(), get_entities_from_private_setting(), get_entities_from_private_setting_multi(), get_entities_in_area(), get_entity_as_row(), ElggCoreObjectTest.get_entity_row(), get_entity_statistics(), get_group_entity_as_row(), get_log_entry(), get_metadata(), get_metastring(), get_notable_entities(), get_notable_entities_from_metadata(), get_noteable_entities_from_relationship(), get_number_users(), get_object_entity_as_row(), ElggCoreObjectTest.get_object_row(), get_objects_in_group(), get_private_setting(), get_relationship(), get_site_by_url(), get_site_entity_as_row(), get_subtype_class(), get_subtype_class_from_id(), get_subtype_from_id(), get_subtype_id(), get_system_log(), get_user_by_code(), get_user_by_username(), get_user_entity_as_row(), ElggHMACCache.load(), search_for_group(), search_for_object(), search_for_site(), search_for_user(), ElggCoreEntityTest.testElggEntityDisableAndEnable(), and validate_user_token().
| get_db_error | ( | $ | dblink | ) |
Get the last database error for a particular database link.
| database | link $dblink |
Definition at line 474 of file database.php.
| get_db_link | ( | $ | dblinktype | ) |
Gets the appropriate db link for the operation mode requested.
| string | $dblinktype The type of link we want - "read", "write" or "readwrite" (the default) |
Definition at line 145 of file database.php.
References setup_db_connections().
Referenced by delete_data(), execute_delayed_read_query(), execute_delayed_write_query(), get_data(), get_data_row(), insert_data(), is_db_installed(), search_init(), and update_data().
| get_db_tables | ( | ) |
Get the tables currently installed in the Elgg database.
Definition at line 427 of file database.php.
References $CONFIG, $result, and get_data().
Referenced by garbagecollector_cron().
| init_db | ( | $ | event, | |
| $ | object_type, | |||
| $ | object = null | |||
| ) |
Alias to setup_db_connections, for use in the event handler.
| string | $event The event type | |
| string | $object_type The object type | |
| mixed | $object Used for nothing in this context |
Definition at line 132 of file database.php.
| insert_data | ( | $ | query | ) |
Use this function to insert database data; returns id or false.
| mixed | $query The query to run. |
Definition at line 352 of file database.php.
References $CONFIG, $DB_QUERY_CACHE, elgg_log(), execute_query(), and get_db_link().
Referenced by __elgg_session_write(), add_entity_relationship(), add_metastring(), add_subtype(), add_to_river(), add_user_to_access_collection(), create_access_collection(), create_annotation(), create_api_user(), create_entity(), create_group_entity(), create_metadata(), create_object_entity(), create_site_entity(), create_user_entity(), create_user_token(), datalist_set(), ElggHMACCache.save(), set_config(), set_private_setting(), and system_log().
| optimize_table | ( | $ | table | ) |
Run an optimize query on a mysql tables.
Useful for executing after major data changes.
Definition at line 463 of file database.php.
References sanitise_string(), and update_data().
Referenced by garbagecollector_cron().
| run_sql_script | ( | $ | scriptlocation | ) |
Runs a full database script from disk.
$CONFIG
| string | $scriptlocation The full path to the script |
Definition at line 484 of file database.php.
References $CONFIG, $e, $error, $errors, $result, $statement, elgg_echo(), and update_data().
Referenced by db_upgrade().
| sanitise_int | ( | $ | int | ) |
Sanitises an integer for database use.
| int | $int |
Definition at line 638 of file database.php.
Referenced by elgg_get_entities(), elgg_get_entity_container_where_sql(), elgg_get_entity_metadata_where_sql(), elgg_get_entity_owner_where_sql(), elgg_get_entity_site_where_sql(), elgg_get_entity_time_where_sql(), elgg_get_tags(), elgg_view_entity_list(), list_entities(), and list_entities_from_annotations().
| sanitise_string | ( | $ | string | ) |
Sanitise a string for database use.
| string | $string The string to sanitise |
Definition at line 615 of file database.php.
References $string.
Referenced by WhereSetQueryComponent.__construct(), WhereStaticQueryComponent.__construct(), WhereQueryComponent.__construct(), SetQueryComponent.__construct(), JoinQueryComponent.__construct(), AccessControlQueryComponent.__construct(), TableQueryComponent.__construct(), OrderQueryComponent.__construct(), SelectFieldQueryComponent.__construct(), __elgg_session_destroy(), __elgg_session_read(), __elgg_session_write(), __get_annotations_calculate_x(), __get_entities_from_annotations_calculate_x(), add_entity_relationship(), add_metastring(), add_subtype(), add_to_river(), add_uuid_to_guid(), ban_user(), callpath_gatekeeper(), check_entity_relationship(), create_access_collection(), create_annotation(), create_entity(), create_group_entity(), create_metadata(), create_object_entity(), create_site_entity(), create_user_entity(), datalist_get(), datalist_set(), ElggHMACCache.delete(), disable_entity(), disable_plugin(), elgg_geocode_location(), elgg_get_entities(), elgg_get_entity_metadata_where_sql(), elgg_get_entity_relationship_where_sql(), elgg_get_tags(), enable_plugin(), find_metadata(), find_plugin_settings(), find_plugin_usersettings(), get_access_sql_suffix(), get_activity_stream_data(), get_annotations(), get_api_user(), get_config(), get_entities_by_relationship_count(), get_entities_from_access_id(), get_entities_from_metadata_groups(), get_entities_from_metadata_groups_multi(), get_entities_from_private_setting(), get_entities_from_private_setting_multi(), get_entities_in_area(), get_entity_dates(), get_entity_from_uuid(), get_entity_icon_url(), get_language_completeness(), get_metastring_id(), get_notable_entities(), get_notable_entities_from_metadata(), get_noteable_entities_from_relationship(), get_objects_in_group(), get_plugin_usersetting(), get_private_setting(), get_river_items(), get_site_by_url(), get_site_collections(), get_site_objects(), get_subtype_class(), get_subtype_id(), get_system_log(), get_user_by_code(), get_user_by_email(), get_user_by_username(), input_livesearch_page_handler(), ElggHMACCache.load(), map_api_hash(), optimize_table(), remove_entity_relationship(), remove_entity_relationships(), remove_metadata(), remove_private_setting(), remove_user_token(), sanitise_string_special(), sanitize_string(), ElggHMACCache.save(), search_comments_hook(), search_for_group(), search_for_object(), search_for_site(), search_for_user(), search_get_where_sql(), search_groups_hook(), search_tags_hook(), search_users_hook(), send_admin_message(), serialise_parameters(), set_config(), set_plugin_usersetting(), set_private_setting(), set_user_notification_setting(), ElggEntity.setIcon(), ElggEntity.setLatLong(), ElggEntity.setLocation(), SimpleQuery.simpleOrder(), SimpleQuery.simpleQueryType(), system_log(), unset_config(), update_annotation(), update_metadata(), uservalidationbyemail_page_handler(), validate_user_token(), and volatile_data_export_plugin_hook().
| sanitise_string_special | ( | $ | string, | |
| $ | extra_escapeable = '' | |||
| ) |
Sanitise a string for database use, but with the option of escaping extra characters.
Definition at line 599 of file database.php.
References $n, $string, and sanitise_string().
| sanitize_int | ( | $ | int | ) |
Wrapper function for alternate English spelling.
| int | $int |
Definition at line 649 of file database.php.
| sanitize_string | ( | $ | string | ) |
Wrapper function for alternate English spelling.
| string | $string The string to sanitise |
Definition at line 628 of file database.php.
References $string, and sanitise_string().
| setup_db_connections | ( | ) |
Establish all database connections.
If the configuration has been set up for multiple read/write databases, set those links up separately; otherwise just create the one database link
Definition at line 83 of file database.php.
References $CONFIG, and establish_db_link().
Referenced by get_db_link().
| update_data | ( | $ | query | ) |
Update database data.
| mixed | $query The query to run. |
Definition at line 377 of file database.php.
References $CONFIG, $DB_QUERY_CACHE, elgg_log(), execute_query(), and get_db_link().
Referenced by archive_log(), ban_user(), create_group_entity(), create_object_entity(), create_site_entity(), create_user_entity(), disable_entity(), disable_user_entities(), enable_entity(), force_user_password_reset(), make_user_admin(), metadata_update(), optimize_table(), remove_user_admin(), run_sql_script(), unban_user(), update_annotation(), update_entity(), update_metadata(), and update_river_access_by_object().
| $DB_DELAYED_QUERIES = array() |
Definition at line 15 of file database.php.
Referenced by db_delayedexecution_shutdown_hook(), and execute_delayed_query().
| $DB_QUERY_CACHE = array() |
Definition at line 14 of file database.php.
Referenced by delete_data(), establish_db_link(), execute_query(), get_data(), get_data_row(), insert_data(), and update_data().
1.6.3