Sets a total number of posts found
@return int
770895
protected function setTotalListBlog()
    {
        $conditions = $this->query_filter;

        $conditions['status'] = 1;
        $conditions['count'] = true;
        $conditions['blog_post'] = 1;
        $conditions['store_id'] = $this->store_id;

        return $this->data_total = (int) $this->page->getList($conditions);
    }
504700
public function have_pages() {
		$this->setup();

		$offset = $this->get_query_offset();

		return (bool) ( $offset < $this->total_posts );
	}
160983
private function get_page_count()
    {
        if ($this->wp_query instanceof WP_User_Query) {
            if (empty($this->wp_query->get_results())) {
                return 0;
            }

            return \ceil($this->wp_query->get_total() / $this->wp_query->query_vars['number']);
        }

        return (int) $this->wp_query->max_num_pages;
    }
955497
public function getTotalPosts()
    {
        global $wpdb;
        return $wpdb->get_var(
            $wpdb->prepare('SELECT COUNT(*)
				FROM ' . $wpdb->prefix . 'posts
				WHERE post_author = %d
				AND post_type = %s
				AND post_status = %s', $this->ID, Post::TYPE_POST, Post::STATUS_PUBLISH));
    }
380931
public function total(array $args = []): int
    {
        $WpDb = $this->s::wpDb();

        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'for_comments_only' => false,

            'include_post_ids' => [],
            'exclude_post_ids' => [],

            'include_post_types' => [],
            'exclude_post_types' => [],

            'include_post_statuses' => [],
            'exclude_post_statuses' => [],

            'exclude_drafts'             => true,
            'exclude_revisions'          => true,
            'exclude_trash'              => true,
            'exclude_password_protected' => false,
            'exclude_nav_menu_items'     => true,

            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        // Also used by {@link all()}.
        $args['for_comments_only'] = (bool) $args['for_comments_only'];

        $args['include_post_ids'] = (array) $args['include_post_ids'];
        $args['exclude_post_ids'] = (array) $args['exclude_post_ids'];

        $args['include_post_types'] = (array) $args['include_post_types'];
        $args['exclude_post_types'] = (array) $args['exclude_post_types'];

        $args['include_post_statuses'] = (array) $args['include_post_statuses'];
        $args['exclude_post_statuses'] = (array) $args['exclude_post_statuses'];

        $args['exclude_drafts']             = (bool) $args['exclude_drafts'];
        $args['exclude_revisions']          = (bool) $args['exclude_revisions'];
        $args['exclude_trash']              = (bool) $args['exclude_trash'];
        $args['exclude_password_protected'] = (bool) $args['exclude_password_protected'];
        $args['exclude_nav_menu_items']     = (bool) $args['exclude_nav_menu_items'];

        $args['no_cache'] = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Build the full SQL based on the arguments/data above.

        $sql = 'SELECT SQL_CALC_FOUND_ROWS `ID` FROM `'.esc_sql($WpDb->posts).'`'.

                ' WHERE 1=1'.// Initialize the WHERE clause in this query.

                ($args['include_post_ids'] ? ' AND `ID` IN('.$this->c::quoteSqlIn($args['include_post_ids']).')' : '').
                ($args['exclude_post_ids'] ? ' AND `ID` NOT IN('.$this->c::quoteSqlIn($args['exclude_post_ids']).')' : '').

                ($args['include_post_types'] ? ' AND `post_type` IN('.$this->c::quoteSqlIn($args['include_post_types']).')' : '').
                ($args['exclude_post_types'] ? ' AND `post_type` NOT IN('.$this->c::quoteSqlIn($args['exclude_post_types']).')' : '').

                ($args['include_post_statuses'] ? ' AND `post_status` IN('.$this->c::quoteSqlIn($args['include_post_statuses']).')' : '').
                ($args['exclude_post_statuses'] ? ' AND `post_status` NOT IN('.$this->c::quoteSqlIn($args['exclude_post_statuses']).')' : '').

                ($args['exclude_drafts'] ? " AND `post_type` NOT IN('draft','auto-draft')" : '').
                ($args['exclude_revisions'] ? " AND `post_type` != 'revision'" : '').
                ($args['exclude_trash'] ? " AND `post_status` != 'trash'" : '').
                ($args['exclude_password_protected'] ? " AND `post_password` = ''" : '').
                ($args['exclude_nav_menu_items'] ? " AND `post_type` != 'nav_menu_item'" : '').

                ($args['for_comments_only'] ? " AND (`comment_status` IN('1', 'open', 'opened') OR `comment_count` > '0')" : '').

                ' LIMIT 1'; // Only one to check `FOUND_ROWS()`.

        // Run the query and return total.

        if ($WpDb->query($sql) === false) {
            throw $this->c::issue('Query failure.');
        }
        return $total = (int) $WpDb->get_var('SELECT FOUND_ROWS()');
    }
922333
public function totalItems()
    {
        $link = $this->_doc->navigation('self');
        return ($link && isset($link->totalitems)) ? $link->totalitems : 0;
    }
111674
public function collectStats()
    {
        Container::get('hooks')->fire('model.index.collect_stats_start');

        // Collect some statistics from the database
        if (!Container::get('cache')->isCached('users_info')) {
            Container::get('cache')->store('users_info', Cache::getUsersInfo());
        }

        $stats = Container::get('cache')->retrieve('users_info');

        $query = DB::forTable('forums')
            ->select_expr('SUM(num_topics)', 'total_topics')
            ->select_expr('SUM(num_posts)', 'total_posts');

        $query = Container::get('hooks')->fireDB('model.index.collect_stats_query', $query);

        $query = $query->find_one();

        $stats['total_topics'] = Utils::numberFormat((int)$query['total_topics']);
        $stats['total_posts'] = Utils::numberFormat((int)$query['total_posts']);

        if (User::get()->g_view_users == '1') {
            $stats['newest_user'] = '<a href="'.
                Router::pathFor('userProfile', ['id' => $stats['last_user']['id']]).'">'.
                Utils::escape($stats['last_user']['username']).'</a>';
        } else {
            $stats['newest_user'] = Utils::escape($stats['last_user']['username']);
        }
        $stats['total_users'] = Utils::numberFormat((int)$stats['total_users']);

        $stats = Container::get('hooks')->fire('model.index.collect_stats', $stats);

        return $stats;
    }
846665
public function getPageCount() : int
    {
        if($this->lastResponse && $this->lastResponse->getHeaderLine('X-Total-Pages')) {
            return (int)$this->lastResponse->getHeaderLine('X-Total-Pages');
        }

        return 0;
    }
1111903
public function setNumTotalResults( $total )
	{
		$total = (int)$total;
		if ( $total < 0 )
		{
			trigger_error( 'Pagination setNumTotalResults: Total must be positive.' );
			return false;
		}

		$this->items_total = $total;
	}
436987
public function count($params = [])
    {
        $this->setSelect('COUNT(*) AS ' . $this->quoteColumnName('total'))
            ->setLimit(-1);
        $record = $this->getDb()
            ->createCommand()
            ->setText($this->buildSql())
            ->queryRow(array_merge($this->getParams(), $params));
        return $record['total'];
    }
177823
public function set_total_users($totalusers) {
        $this->totalusers = $totalusers;
        $this->pages = ceil($this->totalusers / $this->perpage);
        if ($this->page > $this->pages) {
            $this->page = $this->pages;
        }
    }
43625
protected function setPagerListCategory()
    {
        $options = $this->query_filter;
        $options['count'] = true;

        $pager = array(
            'query' => $this->query_filter,
            'total' => (int) $this->category->getList($options)
        );

        return $this->data_limit = $this->setPager($pager);
    }
1154432
protected function setPagerListReportShipping()
    {
        $pager = array(
            'query' => $this->query_filter,
            'total' => (int) $this->getListReportShipping(true)
        );

        return $this->data_limit = $this->setPager($pager);
    }
170474
public static function count_total_users() {
        global $DB, $CFG;
        static $cached = null;
        if ($cached === null) {
            $cached = $DB->count_records_select('user', 'deleted = 0 AND id <> ?', [$CFG->siteguest]);
        }
        return $cached;
    }
93048
protected function calculateTotalItemCount()
	{
		$baseCriteria=$this->model->getDbCriteria(false);
		if($baseCriteria!==null)
			$baseCriteria=clone $baseCriteria;
		$count=$this->model->count($this->getCountCriteria());
		$this->model->setDbCriteria($baseCriteria);
		return $count;
	}
383226
public static function totalThreads()
    {
        $threads = Podium::getInstance()->podiumCache->get('forum.threadscount');
        if ($threads === false) {
            $threads = Thread::find()->count();
            Podium::getInstance()->podiumCache->set('forum.threadscount', $threads);
        }
        return $threads;
    }
105037
protected function countTotalRows()
    {
        $source = $this->getSource();
        /** @var \Doctrine\ORM\Query\Expr\Select $select */
        $source->resetDQLPart('select')->setFirstResult(0)->select('count(' . $this->entityAlias . ')');
        return (int)$source->getQuery()->getSingleScalarResult();
    }