Example #1
0
    protected function do_get($dev_null)
    {
        $data = Database::join('game_set', 'gs.id_game = g.id')->join('user', 'u.id = g.id_user')->join('game_user', 'g.id = gu.id_game and gu.signed_out = 0 and gu.id_user = '******'set', 'gs.id_set = s.id')->group('g.id')->get_table('game', array('g.id, g.id_user, g.state, u.login, g.pick_time, g.update,
				g.pause_time, g.start, g.type', 'group_concat(s.name) as booster', 'gu.id_user as presense'), 'g.state != ? and g.update > ?', array(4, date('Y-m-d G:i:s', time() - 86400)));
        $date_missed = time() - 10800;
        $ids = array();
        foreach ($data as $key => $item) {
            if ($item['state'] > 0 && empty($item['presense']) && strtotime($item['update']) < $date_missed) {
                unset($data[$key]);
                continue;
            }
            if (empty($item['start']) || $item['start'] == '0000-00-00 00:00:00') {
                unset($data[$key]['start']);
            } else {
                $data[$key]['start'] = strtotime($item['start']);
            }
            $ids[] = $item['id'];
        }
        $count = Database::group('id_game')->get_vector('game_user', array('id_game', 'count(`id_user`)'), Database::array_in('id_game', $ids), $ids);
        foreach ($data as $key => $item) {
            $data[$key]['user_count'] = isset($count[$item['id']]) ? $count[$item['id']] : 0;
        }
        return array('success' => true, 'data' => $data);
    }
Example #2
0
 public function get_deck($user, $add_land = false)
 {
     if ($add_land && !$this->land_added($user)) {
         $this->add_land($user);
     }
     return Database::group('gbc.id_card')->join('game_booster', 'gb.id_game_set = gs.id')->join('game_booster_card', 'gbc.id_game_booster = gb.id')->get_table('game_set', array('gbc.id_card', 'count(*) as count', 'sum(gbc.deck) as deck'), 'gs.id_game = ? and gbc.id_user = ?', array($this->get_id(), $user));
 }
Example #3
0
include '../inc.common.php';
$string = 'http://www.pixiv.net/member_illust.php?mode=medium&illust_id=';
$arts = Database::get_vector('art', array('id', 'comment_count'));
$counts = Database::group('post_id')->get_vector('comment', array('post_id', 'count(*)'), 'area != "deleted" and place = "art"');
foreach ($arts as $id => $count) {
    if (isset($counts[$id]) && $count != $counts[$id]) {
        Database::update('art', array('comment_count' => $counts[$id]), $id);
        echo "<br />У арта №{$id} число комментариев изменено с {$count} на " . $counts[$id];
        continue;
    }
    if (!isset($counts[$id]) && $count > 0) {
        Database::update('art', array('comment_count' => 0), $id);
        echo "<br />У арта №{$id} число комментариев изменено с {$count} на 0";
        continue;
    }
}
$posts = Database::get_vector('post', array('id', 'comment_count'));
$counts = Database::group('post_id')->get_vector('comment', array('post_id', 'count(*)'), 'area != "deleted" and place = "post"');
foreach ($posts as $id => $count) {
    if (isset($counts[$id]) && $count != $counts[$id]) {
        Database::update('post', array('comment_count' => $counts[$id]), $id);
        echo "<br />У записи №{$id} число комментариев изменено с {$count} на " . $counts[$id];
        continue;
    }
    if (!isset($counts[$id]) && $count > 0) {
        Database::update('post', array('comment_count' => 0), $id);
        echo "<br />У записи №{$id} число комментариев изменено с {$count} на 0";
        continue;
    }
}