Example #1
0
 public static function last($shift = 0)
 {
     $res = XDB::query('SELECT  id, date, question, answer1, answer2, count1, count2, writer
                        FROM  qdj
                       WHERE  date <= NOW()
                       ORDER  BY date DESC
                       LIMIT  1 OFFSET {?}', $shift)->fetchOneAssoc();
     if ($res !== null) {
         $res['date'] = new FrankizDateTime($res['date']);
         $res['writer'] = new User($res['writer']);
         $qdj = new QDJ($res['id']);
         $qdj->fillFromArray($res);
     } else {
         $qdj = false;
     }
     return $qdj;
 }
Example #2
0
 public function run()
 {
     $qdj = QDJ::last();
     $this->assign('qdj', $qdj);
     $this->assign('votes', $qdj->last_votes());
 }
Example #3
0
 function fetch_scores($begin_date, $end_date, $period)
 {
     if ($period === 'now') {
         $show_min = $begin_date[count($begin_date) - 1];
         $show_max = $end_date[count($end_date) - 1];
     } else {
         if ($period === 'all') {
             $show_min = $begin_date[0];
             $show_max = $end_date[count($end_date) - 1];
         } else {
             $show_min = $begin_date[$period];
             $show_max = $end_date[$period];
         }
     }
     return QDJ::points(new FrankizDateTime(date('Y-m-d', $show_min)), new FrankizDateTime(date('Y-m-d', $show_max)));
 }
Example #4
0
 public function commit()
 {
     $qdj = new QDJ(array('question' => $this->question, 'answer1' => $this->answer1, 'answer2' => $this->answer2, 'writer' => $this->writer));
     $qdj->insert();
     return true;
 }