public function updateAlbum($aid) { $aid = (int) $aid; if (!$aid) { return false; } $album = AlbumService::getAlbumById($aid); if (empty($album)) { return false; } $share_count = (int) FDB::resultFirst('SELECT COUNT(DISTINCT share_id) FROM ' . FDB::table('album_share') . ' WHERE album_id = ' . $aid); $cache_data = array(); $res = FDB::query('SELECT share_id FROM ' . FDB::table('album_share') . ' WHERE album_id = ' . $aid . ' ORDER BY share_id DESC LIMIT 0,6'); $ids = array(); while ($data = FDB::fetch($res)) { $ids[] = $data['share_id']; } if (count($ids) > 0) { $imags = array(); $ids = implode(',', $ids); $res = FDB::query('SELECT share_id,cache_data FROM ' . FDB::table('share') . ' WHERE share_id IN (' . $ids . ') ORDER BY share_id DESC'); while ($data = FDB::fetch($res)) { $data['cache_data'] = unserialize($data['cache_data']); FS('Share')->shareImageFormat($data); unset($data['cache_data']); foreach ($data['imgs'] as $img) { $imags[] = $img; if (count($imags) >= 6) { break; } } if (count($imags) >= 6) { break; } } $cache_data['imgs'] = $imags; } $cache_data = serialize($cache_data); $album = array(); $album['share_count'] = $share_count; $album['cache_data'] = $cache_data; FDB::update('album', $album, 'id = ' . $aid); }
/** * 获得说有图片信息 */ private function album() { $service = new AlbumService(); $result = $service->invoke($this->commonUri); echo json_encode($result); }