wpdb::get_var( string|null $query = null, int $x, int $y )
Retrieve one variable from the database.
Description #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, this function returns the value in the column and row specified. If $query is null, this function returns the value in the specified column and row from the previous SQL result.
Parameters #Parameters
- $query
-
(string|null) (Optional) SQL query. Defaults to null, use the result from the previous query.
Default value: null
- $x
-
(int) (Optional) Column of value to return. Indexed from 0.
- $y
-
(int) (Optional) Row of value to return. Indexed from 0.
Return #Return
(string|null) Database query result (as string), or null on failure
Source #Source
File: wp-includes/wp-db.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; }
Expand full source code Collapse full source code View on Trac
Changelog #Changelog
Version | Description |
---|---|
0.71 | Introduced. |
Related #Related
Uses #Uses
Uses | Description |
---|---|
wp-includes/wp-db.php: wpdb::check_safe_collation() |
Check if the query is accessing a collation considered safe on the current version of MySQL. |
wp-includes/wp-db.php: wpdb::query() |
Perform a MySQL database query, using current database connection. |
Used By #Used By
Used By | Description |
---|---|
wp-admin/includes/class-wp-debug-data.php: WP_Debug_Data::debug_data() |
Static function for generating site debug data when required. |
wp-admin/includes/class-wp-site-health.php: WP_Site_Health::prepare_sql_data() |
Run the SQL version checks. |
wp-includes/functions.php: is_site_meta_supported() |
Determines whether site meta is enabled. |
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/comment.php: wp_check_comment_flood() |
Checks whether comment flooding is occurring. |
wp-includes/class-wp-term-query.php: WP_Term_Query::get_terms() |
Get terms, based on 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/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-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/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/taxonomy.php: wp_term_is_shared() |
Determine whether a term is shared between multiple taxonomies. |
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/media.php: attachment_url_to_postid() |
Tries to convert an attachment URL into a post ID. |
wp-admin/includes/network.php: network_step2() |
Prints step 2 for Network installation process. |
wp-admin/includes/network.php: network_domain_check() |
Check for an existing network. |
wp-admin/install.php: display_setup_form() |
Display installer setup form. |
wp-admin/includes/deprecated.php: WP_User_Search::query() |
Executes the user search query. |
wp-admin/includes/schema.php: populate_network() |
Populate network settings. |
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: maybe_create_table() |
Creates a table in the database if it doesn’t already exist. |
wp-admin/includes/upgrade.php: upgrade_network() |
Executes network-level upgrade routines. |
wp-admin/includes/upgrade.php: wp_install_defaults() |
Creates the initial content for a newly-installed site. |
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/post.php: post_exists() |
Determines if a post exists based on title, content, date and type. |
wp-admin/includes/comment.php: comment_exists() |
Determine if a comment exists based on author and date. |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::__construct() |
Constructor. |
wp-includes/pluggable.php: wp_notify_moderator() |
Notifies the moderator of the site about a new comment that is awaiting approval. |
wp-includes/general-template.php: get_calendar() |
Display calendar with days that have posts as links. |
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/functions.php: is_blog_installed() |
Determines whether WordPress is already installed. |
wp-includes/functions.php: do_enclose() |
Check content for video and audio links to add as enclosures. |
wp-includes/taxonomy.php: _update_post_term_count() |
Will update term count based on object types of the current taxonomy. |
wp-includes/taxonomy.php: _update_generic_term_count() |
Will update term count based on number of objects. |
wp-includes/taxonomy.php: wp_unique_term_slug() |
Will make slug unique, if it isn’t already. |
wp-includes/taxonomy.php: wp_update_term() |
Update term based on arguments provided. |
wp-includes/taxonomy.php: wp_set_object_terms() |
Create Term and Taxonomy Relationships. |
wp-includes/taxonomy.php: wp_insert_term() |
Add a new term to the database. |
wp-includes/taxonomy.php: wp_delete_term() |
Removes a term from the database. |
wp-includes/taxonomy.php: term_exists() |
Determines whether a term exists. |
wp-includes/link-template.php: get_adjacent_post() |
Retrieves the adjacent post. |
wp-includes/http.php: ms_allowed_http_request_hosts() |
Whitelists any domain in a multisite installation for safe HTTP requests. |
wp-includes/class-wp-user-query.php: WP_User_Query::query() |
Execute the query, with the current variables. |
wp-includes/user.php: wp_insert_user() |
Insert a user into the database. |
wp-includes/user.php: count_user_posts() |
Number of posts user has written. |
wp-includes/media.php: wp_enqueue_media() |
Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. |
wp-includes/post.php: _get_last_post_time() |
Gets the timestamp of the last time any post was modified or published. |
wp-includes/post.php: get_page_by_title() |
Retrieve 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() |
Insert or update a post. |
wp-includes/post.php: wp_count_attachments() |
Count number of attachments for the mime type(s). |
wp-includes/canonical.php: redirect_guess_404_permalink() |
Attempts to guess the correct URL based on query vars |
wp-includes/canonical.php: redirect_canonical() |
Redirects incoming links to the proper URL based on the site url. |
wp-includes/ms-functions.php: wp_update_network_user_counts() |
Update the network-wide user count. |
wp-includes/ms-functions.php: update_posts_count() |
Update a blog’s post count. |
wp-includes/ms-functions.php: global_terms() |
Maintains a canonical list of terms by syncing terms created for each blog with the global terms table. |
wp-includes/ms-functions.php: wpmu_validate_blog_signup() |
Processes new site registrations. |
wp-includes/ms-load.php: ms_not_installed() |
Displays a failure message. |
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() |
Get a blog details field. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::pingback_ping() |
Retrieves a pingback and registers it. |
wp-includes/wp-db.php: wpdb::get_col() |
Retrieve one column from the database. |
wp-includes/comment.php: wp_update_comment_count_now() |
Updates the comment count for the post. |
wp-includes/comment.php: get_lastcommentmodified() |
The date the last comment was modified. |
wp-includes/comment.php: wp_allow_comment() |
Validates whether this comment is allowed to be made. |
wp-includes/comment.php: check_comment() |
Check whether a comment passes internal checks to be allowed to add. |
wp-includes/meta.php: add_metadata() |
Add metadata for the specified object. |
User Contributed Notes #User Contributed Notes
You must log in before being able to contribute a note or feedback.
get total post from an user:
// Retrieve and display the number of users.