本文整理汇总了PHP中Subjects::order方法的典型用法代码示例。如果您正苦于以下问题:PHP Subjects::order方法的具体用法?PHP Subjects::order怎么用?PHP Subjects::order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subjects
的用法示例。
在下文中一共展示了Subjects::order方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleLikedSubjects
public function handleLikedSubjects()
{
$this->tab = 'likedSubjects';
$res = $this->context->database->table('subject_rating')->select('subject_id, SUM(thumb_up) AS thumb_up, SUM(thumb_down) AS thumb_down')->order('thumb_up DESC, thumb_down')->group('subject_id');
foreach ($res as $key => $row) {
$ids[] = $row['subject_id'];
}
if (isset($ids)) {
$this->subjects->where('id', $ids);
$this->subjects->order('FIND_IN_SET(subject.id,"' . implode(",", $ids) . '")');
} else {
$this->subjects->where('id', '-2');
}
$this->refresh();
}
示例2: renderDefault
public function renderDefault()
{
$this->template->subjects = $this->places->order('name')->where('subject.id != 1')->group('subject.id')->having('COUNT(:event.id) > 0');
$this->template->approvedPlacesCount = $this->approvedPlacesCount;
$this->template->subject_id = $this->subject_id;
if ($this->subject_id != 'all') {
$this->events->where('subject_id', $this->subject_id)->group('event.id')->having('COUNT(:event_time.id) = 0');
}
// vyhledavani
if ($this->q) {
$this->events->where("event.name LIKE ? OR subject.name LIKE ? OR user.email LIKE ?", "%" . $this->q . "%", "%" . $this->q . "%", "%" . $this->q . "%");
$this->places->where("subject.name LIKE ?", "%" . $this->q . "%");
$this['search']['q']->setDefaultValue($this->q);
$this->template->search = TRUE;
} else {
$this->template->search = FALSE;
}
if ($this->order == '' && $this->user->isInRole('administrator')) {
$this->order = 'updated DESC';
}
switch ($this->what) {
case self::ANONYMOUS:
$this->events->where('subject_id', '1');
$this->template->what = self::ANONYMOUS;
break;
case self::NOTERM:
$this->events->group('event.id')->having('COUNT(:event_time.id) = 0');
$this->template->what = self::NOTERM;
break;
case self::UPDATED:
$this->events->group('event.id')->having('DATEDIFF(NOW(), event.changed) < ' . self::TIME_UPDATED);
$this->template->what = self::UPDATED;
break;
case self::RECENT:
$this->events->group('event.id')->having('DATEDIFF(NOW(), event.created) < ' . self::TIME_RECENT);
$this->template->what = self::UPDATED;
break;
case self::TOREVIEW:
$this->events->group('event.id')->having('event.reviewed = 0');
$this->template->what = self::TOREVIEW;
break;
case self::NOTAPPROVED:
$this->events->group('event.id')->having('event.approved = 0');
$this->template->what = self::NOTAPPROVED;
break;
case self::PREFERED:
$this->events->group('event.id')->having('event.prefered = 1');
$this->template->what = self::PREFERED;
break;
default:
$this->template->what = self::ALL;
}
if ($this->orderBy == '' && $this->user->isInRole('administrator')) {
$this->orderBy = self::MODIFICATION;
}
switch ($this->orderBy) {
case self::MODIFICATION:
$this->events->order('changed DESC, created DESC');
$this->template->orderBy = self::MODIFICATION;
break;
case self::ALPHABET:
default:
$this->events->order('name');
$this->template->orderBy = self::ALPHABET;
break;
}
$this->pagerEvents->itemCount = $this->events->count();
$this->template->events = $this->events->limit($this->pagerEvents->getLimit(), $this->pagerEvents->getOffset());
if ($this->user->isInRole('administrator')) {
$this->template->nonaproved = $this->context->createServiceEvents()->where('approved', '0');
}
}