本文整理汇总了PHP中bp_core_get_status_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_get_status_sql函数的具体用法?PHP bp_core_get_status_sql怎么用?PHP bp_core_get_status_sql使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_get_status_sql函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_core_get_total_member_count
/**
* Return the total number of members for the installation.
*
* Note that this is a raw count of non-spam, activated users. It does not
* account for users who have logged activity (last_active). See
* {@link bp_core_get_active_member_count()}.
*
* @since 1.2.0
*
* @return int The total number of members.
*/
function bp_core_get_total_member_count()
{
global $wpdb;
$count = wp_cache_get('bp_total_member_count', 'bp');
if (false === $count) {
$status_sql = bp_core_get_status_sql();
$count = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}");
wp_cache_set('bp_total_member_count', $count, 'bp');
}
/**
* Filters the total number of members for the installation.
*
* @since 1.2.0
*
* @param int $count Total number of members.
*/
return apply_filters('bp_core_get_total_member_count', $count);
}
示例2: prepare_user_ids_query
//.........这里部分代码省略.........
$this->uid_table = $wpdb->usermeta;
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
$sql['where'][] = $wpdb->prepare("u.meta_key = %s", bp_get_user_meta_key('total_friend_count'));
$sql['orderby'] = "ORDER BY CONVERT(u.meta_value, SIGNED)";
$sql['order'] = "DESC";
break;
// 'alphabetical' sorts depend on the xprofile setup.
// 'alphabetical' sorts depend on the xprofile setup.
case 'alphabetical':
// We prefer to do alphabetical sorts against the display_name field
// of wp_users, because the table is smaller and better indexed. We
// can do so if xprofile sync is enabled, or if xprofile is inactive.
//
// @todo remove need for bp_is_active() check.
if (!bp_disable_profile_sync() || !bp_is_active('xprofile')) {
$this->uid_name = 'ID';
$this->uid_table = $wpdb->users;
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
$sql['orderby'] = "ORDER BY u.display_name";
$sql['order'] = "ASC";
// When profile sync is disabled, alphabetical sorts must happen against
// the xprofile table.
} else {
$this->uid_name = 'user_id';
$this->uid_table = $bp->profile->table_name_data;
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
$sql['where'][] = $wpdb->prepare("u.field_id = %d", bp_xprofile_fullname_field_id());
$sql['orderby'] = "ORDER BY u.value";
$sql['order'] = "ASC";
}
// Alphabetical queries ignore last_activity, while BP uses last_activity
// to infer spam/deleted/non-activated users. To ensure that these users
// are filtered out, we add an appropriate sub-query.
$sql['where'][] = "u.{$this->uid_name} IN ( SELECT ID FROM {$wpdb->users} WHERE " . bp_core_get_status_sql('') . " )";
break;
// Any other 'type' falls through.
// Any other 'type' falls through.
default:
$this->uid_name = 'ID';
$this->uid_table = $wpdb->users;
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
// In this case, we assume that a plugin is
// handling order, so we leave those clauses
// blank.
break;
}
/* WHERE *************************************************************/
// 'include' - User ids to include in the results.
$include = false !== $include ? wp_parse_id_list($include) : array();
$include_ids = $this->get_include_ids($include);
if (!empty($include_ids)) {
$include_ids = implode(',', wp_parse_id_list($include_ids));
$sql['where'][] = "u.{$this->uid_name} IN ({$include_ids})";
}
// 'exclude' - User ids to exclude from the results.
if (false !== $exclude) {
$exclude_ids = implode(',', wp_parse_id_list($exclude));
$sql['where'][] = "u.{$this->uid_name} NOT IN ({$exclude_ids})";
}
// 'user_id' - When a user id is passed, limit to the friends of the user
// @todo remove need for bp_is_active() check.
if (!empty($user_id) && bp_is_active('friends')) {
$friend_ids = friends_get_friend_user_ids($user_id);
$friend_ids = implode(',', wp_parse_id_list($friend_ids));
if (!empty($friend_ids)) {
$sql['where'][] = "u.{$this->uid_name} IN ({$friend_ids})";
示例3: bp_core_get_total_member_count
/**
* Returns the total number of members for the installation.
*
* @package BuddyPress Core
* @return int The total number of members.
*/
function bp_core_get_total_member_count()
{
global $wpdb, $bp;
if (!($count = wp_cache_get('bp_total_member_count', 'bp'))) {
$status_sql = bp_core_get_status_sql();
$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}"));
wp_cache_set('bp_total_member_count', $count, 'bp');
}
return apply_filters('bp_core_get_total_member_count', $count);
}
示例4: search_users
/**
* Find users who match on the value of an xprofile data.
*
* @global wpdb $wpdb WordPress database object.
*
* @param string $search_terms The terms to search the profile table
* value column for.
* @param integer $limit The limit of results we want.
* @param integer $page The page we are on for pagination.
* @param boolean $populate_extras Populate extra user fields?
* @return array Associative array.
*/
public static function search_users($search_terms, $limit = null, $page = 1, $populate_extras = true)
{
global $wpdb;
$bp = buddypress();
$user_ids = array();
$pag_sql = $limit && $page ? $wpdb->prepare(" LIMIT %d, %d", intval(($page - 1) * intval($limit)), intval($limit)) : '';
$search_terms_like = '%' . bp_esc_like($search_terms) . '%';
$status_sql = bp_core_get_status_sql('u.');
/**
* Filters the SQL used to query for searched users count.
*
* @since BuddyPress (1.0.0)
*
* @param string $value SQL statement for the searched users count query.
*/
$total_users_sql = apply_filters('bp_core_search_users_count_sql', $wpdb->prepare("SELECT COUNT(DISTINCT u.ID) as id FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", $search_terms_like), $search_terms);
/**
* Filters the SQL used to query for searched users.
*
* @since BuddyPress (1.0.0)
*
* @param string $value SQL statement for the searched users query.
*/
$paged_users_sql = apply_filters('bp_core_search_users_sql', $wpdb->prepare("SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", $search_terms_like), $search_terms, $pag_sql);
$total_users = $wpdb->get_var($total_users_sql);
$paged_users = $wpdb->get_results($paged_users_sql);
/***
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
*/
foreach ((array) $paged_users as $user) {
$user_ids[] = $user->id;
}
// Add additional data to the returned results
if ($populate_extras) {
$paged_users = BP_Core_User::get_user_extras($paged_users, $user_ids);
}
return array('users' => $paged_users, 'total' => $total_users);
}
示例5: search_users
/**
* Find users who match on the value of an xprofile data.
*
* @global object $bp Global BuddyPress settings object
* @global nxtdb $nxtdb NXTClass database object
* @param string $search_terms The terms to search the profile table value column for.
* @param integer $limit The limit of results we want.
* @param integer $page The page we are on for pagination.
* @param boolean $populate_extras Populate extra user fields?
* @return array Associative array
* @static
*/
function search_users($search_terms, $limit = null, $page = 1, $populate_extras = true)
{
global $bp, $nxtdb;
$pag_sql = $limit && $page ? $nxtdb->prepare(" LIMIT %d, %d", intval(($page - 1) * intval($limit)), intval($limit)) : '';
$search_terms = like_escape($nxtdb->escape($search_terms));
$status_sql = bp_core_get_status_sql('u.');
$total_users_sql = apply_filters('bp_core_search_users_count_sql', "SELECT COUNT(DISTINCT u.ID) as id FROM {$nxtdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%{$search_terms}%%' ORDER BY pd.value ASC", $search_terms);
$paged_users_sql = apply_filters('bp_core_search_users_sql', "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$nxtdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%{$search_terms}%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql);
$total_users = $nxtdb->get_var($total_users_sql);
$paged_users = $nxtdb->get_results($paged_users_sql);
/***
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
*/
foreach ((array) $paged_users as $user) {
$user_ids[] = $user->id;
}
$user_ids = $nxtdb->escape(join(',', (array) $user_ids));
// Add additional data to the returned results
if ($populate_extras) {
$paged_users = BP_Core_User::get_user_extras($paged_users, $user_ids);
}
return array('users' => $paged_users, 'total' => $total_users);
}