ActivityModel::getCount PHP Метод

getCount() публичный Метод

Events: BeforeGetCount.
С версии: 2.0.0
public getCount ( string $UserID = '' ) : integer
$UserID string Unique ID of user.
Результат integer Number of activity items found.
    public function getCount($UserID = '')
    {
        $this->SQL->select('a.ActivityID', 'count', 'ActivityCount')->from('Activity a')->join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID');
        if ($UserID != '') {
            $this->SQL->beginWhereGroup()->where('a.ActivityUserID', $UserID)->orWhere('a.RegardingUserID', $UserID)->endWhereGroup();
        }
        $Session = Gdn::session();
        if (!$Session->isValid() || $Session->UserID != $UserID) {
            $this->SQL->where('t.Public', '1');
        }
        $this->fireEvent('BeforeGetCount');
        return $this->SQL->get()->firstRow()->ActivityCount;
    }

Usage Example

 public function lists()
 {
     $page = intval(Input::get('page', 1));
     $start_time = Input::get('start_time', '');
     $expire = Input::get('expire', '');
     $args = ['start_time' => $start_time, 'expire' => $expire];
     $model = new ActivityModel();
     $count = $model->getCount($args);
     $rows = $model->getRows($page, $args);
     $page_size = Pagination::getPageSize($count);
     return View::make('activity.lists', ['rows' => $rows, 'page' => $page, 'page_size' => $page_size, 'params' => $args]);
 }