Example #1
0
 public static function getPollsInfo($sorting_field, $sorting_order, $limit, $num_rows, &$pollsCount)
 {
     $order = 'ORDER BY ';
     switch ($sorting_field) {
         case 'user_group':
             $order .= " user_group_sid {$sorting_order}";
             break;
         case 'status':
             $order .= " `active` {$sorting_order}";
             break;
         default:
             $order .= " {$sorting_field}  {$sorting_order}";
             break;
     }
     $pollsCount = count(SJB_DB::query('SELECT * FROM `polls`'));
     $result = SJB_DB::query("SELECT * FROM `polls` {$order} LIMIT {$limit}, {$num_rows}");
     $polls = array();
     foreach ($result as $key => $val) {
         $polls[$key] = $val;
         if (!empty($val['user_group_sid'])) {
             $polls[$key]['user_group'] = SJB_UserGroupManager::getUserGroupNameBySID($val['user_group_sid']);
         } else {
             $polls[$key]['user_group'] = 'All';
         }
     }
     return $polls;
 }