wpdb::get_var( string|null $query = null, int $x, int $y )
Retrieves one variable from the database.
Description
Executes a SQL query and returns the value from the SQL result.
If the SQL result contains more than one column and/or more than one row, the value in the column and row specified is returned. If $query is null, the value in the specified column and row from the previous SQL result is returned.
Parameters
- $query
-
(Optional) SQL query. Defaults to null, use the result from the previous query.
Default value: null
- $x
-
(Optional) Column of value to return. Indexed from 0. Default 0.
- $y
-
(Optional) Row of value to return. Indexed from 0. Default 0.
Return
(string|null) Database query result (as string), or null on failure.
Source
File: wp-includes/class-wpdb.php
public function get_var( $query = null, $x = 0, $y = 0 ) {
$this->func_call = "\$db->get_var(\"$query\", $x, $y)";
if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
$this->check_current_query = false;
}
if ( $query ) {
$this->query( $query );
}
// Extract var out of cached results based x,y vals
if ( !empty( $this->last_result[$y] ) ) {
$values = array_values( get_object_vars( $this->last_result[$y] ) );
}
// If there is a value return it else return null
return ( isset( $values[$x] ) && $values[$x] !== '' ) ? $values[$x] : null;
}
Related
Uses
Uses | Description |
---|---|
wp-includes/class-wpdb.php: wpdb::check_safe_collation() |
Checks if the query is accessing a collation considered safe on the current version of MySQL. |
wp-includes/class-wpdb.php: wpdb::query() |
Performs a database query, using current database connection. |
Used By
Used By | Description |
---|---|
wp-admin/includes/class-wp-site-health.php: WP_Site_Health::prepare_sql_data() |
Runs the SQL version checks. |
wp-admin/includes/class-wp-debug-data.php: WP_Debug_Data::debug_data() |
Static function for generating site debug data when required. |
wp-includes/user.php: wp_update_user_counts() |
Updates the total count of users on the site. |
wp-includes/comment.php: _wp_batch_update_comment_type() |
Updates the comment type for a batch of comments. |
wp-includes/functions.php: is_site_meta_supported() |
Determines whether site meta is enabled. |
wp-includes/general-template.php: get_calendar() |
Displays calendar with days that have posts as links. |
wp-includes/class-wp-user-query.php: WP_User_Query::query() |
Executes the query, with the current variables. |
wp-includes/class-wp-query.php: WP_Query::set_found_posts() |
Set up the amount of found posts and the number of pages (if limit clause was used) for the current query. |
wp-includes/query.php: _find_post_by_old_slug() |
Find the post ID for redirecting an old slug. |
wp-includes/query.php: _find_post_by_old_date() |
Find the post ID for redirecting an old date. |
wp-includes/pluggable.php: wp_notify_moderator() |
Notifies the moderator of the site about a new comment that is awaiting approval. |
wp-includes/class-wp-network-query.php: WP_Network_Query::get_network_ids() |
Used internally to get a list of network IDs matching the query vars. |
wp-includes/class-wp-network-query.php: WP_Network_Query::set_found_networks() |
Populates found_networks and max_num_pages properties for the current query if the limit clause was used. |
wp-includes/comment.php: wp_update_comment_count_now() |
Updates the comment count for the post. |
wp-includes/comment.php: wp_allow_comment() |
Validates whether this comment is allowed to be made. |
wp-includes/comment.php: wp_check_comment_flood() |
Checks whether comment flooding is occurring. |
wp-includes/comment.php: check_comment() |
Checks whether a comment passes internal checks to be allowed to add. |
wp-includes/comment.php: get_lastcommentmodified() |
Retrieves the date the last comment was modified. |
wp-includes/ms-load.php: ms_not_installed() |
Displays a failure message. |
wp-includes/link-template.php: get_adjacent_post() |
Retrieves the adjacent post. |
wp-includes/ms-deprecated.php: get_blog_list() |
Deprecated functionality to retrieve a list of all sites. |
wp-includes/ms-blogs.php: get_blog_status() |
Gets a blog details field. |
wp-includes/meta.php: add_metadata() |
Adds metadata for the specified object. |
wp-includes/http.php: ms_allowed_http_request_hosts() |
Adds any domain in a multisite installation for safe HTTP requests to the allowed list. |
wp-includes/user.php: wp_insert_user() |
Inserts a user into the database. |
wp-includes/user.php: count_user_posts() |
Gets the number of posts a user has written. |
wp-includes/class-wpdb.php: wpdb::get_col() |
Retrieves one column from the database. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::pingback_ping() |
Retrieves a pingback and registers it. |
wp-includes/canonical.php: redirect_canonical() |
Redirects incoming links to the proper URL based on the site url. |
wp-includes/canonical.php: redirect_guess_404_permalink() |
Attempts to guess the correct URL for a 404 request based on query vars. |
wp-includes/class-wp-term-query.php: WP_Term_Query::get_terms() |
Retrieves the query results. |
wp-includes/post.php: _get_last_post_time() |
Gets the timestamp of the last time any post was modified or published. |
wp-includes/deprecated.php: get_page_by_title() |
Retrieves a page given its title. |
wp-includes/post.php: wp_unique_post_slug() |
Computes a unique slug for the post, when given the desired slug and some post details. |
wp-includes/post.php: wp_insert_post() |
Inserts or update a post. |
wp-includes/post.php: wp_count_attachments() |
Counts number of attachments for the mime type(s). |
wp-includes/class-wp-site-query.php: WP_Site_Query::get_site_ids() |
Used internally to get a list of site IDs matching the query vars. |
wp-includes/class-wp-site-query.php: WP_Site_Query::set_found_sites() |
Populates found_sites and max_num_pages properties for the current query if the limit clause was used. |
wp-includes/ms-functions.php: update_posts_count() |
Updates a blog’s post count. |
wp-includes/ms-functions.php: wpmu_validate_blog_signup() |
Processes new site registrations. |
wp-includes/class-wp-comment-query.php: WP_Comment_Query::get_comment_ids() |
Used internally to get a list of comment IDs matching the query vars. |
wp-includes/class-wp-comment-query.php: WP_Comment_Query::set_found_comments() |
Populates found_comments and max_num_pages properties for the current query if the limit clause was used. |
wp-includes/taxonomy.php: wp_term_is_shared() |
Determines whether a term is shared between multiple taxonomies. |
wp-includes/taxonomy.php: _update_post_term_count() |
Updates term count based on object types of the current taxonomy. |
wp-includes/taxonomy.php: _update_generic_term_count() |
Updates term count based on number of objects. |
wp-includes/taxonomy.php: wp_unique_term_slug() |
Makes term slug unique, if it isn’t already. |
wp-includes/taxonomy.php: wp_update_term() |
Updates term based on arguments provided. |
wp-includes/taxonomy.php: wp_delete_term() |
Removes a term from the database. |
wp-includes/taxonomy.php: wp_set_object_terms() |
Creates term and taxonomy relationships. |
wp-includes/taxonomy.php: wp_insert_term() |
Adds a new term to the database. |
wp-includes/functions.php: is_blog_installed() |
Determines whether WordPress is already installed. |
wp-includes/functions.php: do_enclose() |
Checks content for video and audio links to add as enclosures. |
wp-admin/includes/deprecated.php: WP_User_Search::query() |
Executes the user search query. |
wp-admin/includes/media.php: update_gallery_tab() |
Adds the gallery tab back to the tabs array if post has image attachments. |
wp-admin/includes/schema.php: populate_network() |
Populate network settings. |
wp-admin/includes/network.php: network_domain_check() |
Check for an existing network. |
wp-admin/includes/network.php: network_step2() |
Prints step 2 for Network installation process. |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::__construct() |
Constructor. |
wp-admin/includes/comment.php: comment_exists() |
Determines if a comment exists based on author and date. |
wp-admin/includes/upgrade.php: maybe_disable_link_manager() |
Disables the Link Manager on upgrade if, at the time of upgrade, no links exist in the DB. |
wp-admin/includes/upgrade.php: pre_schema_upgrade() |
Runs before the schema is upgraded. |
wp-admin/includes/upgrade.php: upgrade_network() |
Executes network-level upgrade routines. |
wp-admin/includes/post.php: post_exists() |
Determines if a post exists based on title, content, date and type. |
wp-admin/install-helper.php: maybe_create_table() |
Creates a table in the database if it doesn’t already exist. |
wp-admin/install.php: display_setup_form() |
Displays installer setup form. |
Changelog
Version | Description |
---|---|
0.71 | Introduced. |