UserModel::counts PHP Method

counts() public method

User counts.
public counts ( string $Column, integer | null $UserID = null )
$Column string The name of the count column. (ex. CountDiscussions, CountComments).
$UserID integer | null The user ID to get the counts for or **null** for the current user.
    public function counts($Column, $UserID = null)
    {
        if ($UserID > 0) {
            $Where = ['UserID' => $UserID];
        } else {
            $Where = null;
        }
        switch (strtolower($Column)) {
            case 'countdiscussions':
                Gdn::database()->query(DBAModel::getCountSQL('count', 'User', 'Discussion', 'CountDiscussions', 'DiscussionID', 'UserID', 'InsertUserID', $Where));
                break;
            case 'countcomments':
                Gdn::database()->query(DBAModel::getCountSQL('count', 'User', 'Comment', 'CountComments', 'CommentID', 'UserID', 'InsertUserID', $Where));
                break;
        }
        if ($UserID > 0) {
            $this->clearCache($UserID);
        }
    }
UserModel