本文整理汇总了PHP中Album::where_in方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::where_in方法的具体用法?PHP Album::where_in怎么用?PHP Album::where_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::where_in方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aggregate
//.........这里部分代码省略.........
$c->include_related('album')->where("YEAR(FROM_UNIXTIME({$c->table}.published_on{$shift}))", $options['year'])->where("MONTH(FROM_UNIXTIME({$c->table}.published_on{$shift}))", $options['month'])->where("DAY(FROM_UNIXTIME({$c->table}.published_on{$shift}))", $options['day'])->group_start()->where($a->table . '.id', null)->or_where($a->table . '.deleted', 0)->group_end();
} else {
if ($type === 'tag') {
$c->where_related('tag', 'id', $options['tag']);
} else {
$c->where_related('category', 'id', $options['category']);
}
}
if ($options['featured']) {
$c->where('featured', 1);
}
$c->order_by($c->table . '.published_on DESC')->get_iterated();
foreach ($c as $content) {
if ($content->album_id && $content->album_visibility < 1 && $content->album_published_on <= $date_marker) {
if (!isset($updated_album_ids[$content->album_id])) {
$updated_album_ids[$content->album_id] = array('items' => array($content->id), 'date' => $content->published_on, 'featured' => $content->album_featured);
} else {
$updated_album_ids[$content->album_id]['items'][] = $content->id;
$updated_album_ids[$content->album_id]['date'] = max($content->published_on, $updated_album_ids[$content->album_id]['date']);
}
} else {
if (!$content->album_id) {
$content_ids[$content->id] = $content->published_on;
$aggregate[] = array('type' => 'content', 'id' => $content->id, 'date' => $content->published_on, 'featured' => $content->featured);
}
}
}
foreach ($updated_album_ids as $id => $a) {
$aggregate[] = array('type' => 'updated_album', 'id' => $id, 'date' => $a['date'], 'featured' => $a['featured']);
}
$total = count($aggregate);
if (!function_exists('_sort')) {
function _sort($one, $two)
{
if ($one['featured'] && !$two['featured']) {
return -1;
} else {
if ($one['featured'] && $two['featured']) {
return $one['date'] < $two['date'] ? 1 : -1;
}
}
return $two['featured'] || $one['date'] < $two['date'] || $one['date'] === $two['date'] && $two['id'] > $one['id'] ? 1 : -1;
}
}
usort($aggregate, '_sort');
$stream = array('page' => (int) isset($options['page']) ? (int) $options['page'] : 1, 'pages' => (int) ceil($total / $options['limit']), 'per_page' => (int) min($options['limit'], $total), 'total' => (int) $total);
$load = array_slice($aggregate, ($stream['page'] - 1) * $options['limit'], $options['limit']);
$counts = array('essays' => count($essay_ids), 'albums' => count($album_ids), 'content' => count($content_ids));
$counts['total'] = $counts['essays'] + $counts['albums'] + $counts['content'];
$updated_album_ids_arr = $updated_album_ids;
$essay_ids = $album_ids = $content_ids = $updated_album_ids = $final = $index = array();
foreach ($load as $i => $item) {
$index[$item['type'] . '-' . $item['id']] = $i;
${$item['type'] . '_ids'}[] = $item['id'];
}
if (!empty($essay_ids)) {
$e = new Text();
$e->where_in('id', $essay_ids)->get_iterated();
foreach ($e as $essay) {
$final[$index['essay-' . $essay->id]] = $essay->to_array($shared_params);
}
}
if (!empty($album_ids)) {
$a = new Album();
$a->where_in('id', $album_ids)->get_iterated();
foreach ($a as $album) {
$final[$index['album-' . $album->id]] = $album->to_array($album_params);
}
}
if (!empty($content_ids)) {
$c = new Content();
$c->where_in('id', $content_ids)->get_iterated();
foreach ($c as $content) {
$final[$index['content-' . $content->id]] = $content->to_array(array_merge($shared_params, array('order_by' => 'published_on')));
}
}
if (!empty($updated_album_ids)) {
$a = new Album();
$a->where_in('id', $updated_album_ids)->get_iterated();
foreach ($a as $album) {
$arr = $album->to_array();
$arr['event_type'] = 'album_update';
$arr['content'] = array();
$info = $updated_album_ids_arr[$album->id];
$c = new Content();
$c->where_in('id', $info['items'])->order_by('published_on DESC')->get_iterated();
foreach ($c as $i => $content) {
$carr = $content->to_array(array('order_by' => 'published_on', 'in_album' => $album));
if ($i === 0) {
$arr['date'] = $carr['date'];
}
$arr['content'][] = $carr;
}
$final[$index['updated_album-' . $album->id]] = $arr;
}
}
ksort($final);
$stream['items'] = array_values($final);
return array($stream, $counts);
}
示例2: explode
function _order($order, $album = false)
{
$ids = explode(',', $order);
$new_order_map = array();
foreach ($ids as $key => $val) {
$pos = $key + 1;
$new_order_map[$val] = $pos;
}
$contents = new Album();
$contents->where_in('id', $ids);
$sql = $contents->get_sql() . ' ORDER BY FIELD(id, ' . join(',', $ids) . ')';
$contents->query($sql);
$next_slot = $album ? $album->left_id + 1 : 1;
$this->db->trans_begin();
$start = strtotime(gmdate("M d Y H:i:s", time()));
foreach ($contents as $sub_album) {
$size = $sub_album->right_id - $sub_album->left_id + 1;
if ($sub_album->left_id != $next_slot) {
$delta = $sub_album->left_id - $next_slot;
$delta = $delta >= 0 ? '- ' . $delta : '+ ' . abs($delta);
$_a = new Album();
$_a->where('left_id >=', $sub_album->left_id)->where('right_id <=', $sub_album->right_id)->where('level >=', $sub_album->level)->where('modified_on <', $start)->update(array('left_id' => "left_id {$delta}", 'right_id' => "right_id {$delta}", 'modified_on' => $start), false);
}
$next_slot += $size;
}
$this->db->trans_complete();
}
示例3: topics
function topics()
{
list($params, $id) = $this->parse_params(func_get_args());
if ($this->method === 'get') {
$a = new Album();
$params['auth'] = $this->auth;
$params['flat'] = true;
$final = $a->where_related('text', 'id', $id)->listing($params);
$this->set_response_data($final);
} else {
list($text_id, $album_id) = $id;
$text = new Text();
$t = $text->get_by_id($text_id);
if (is_numeric($album_id)) {
$album_id = array($album_id);
} else {
$album_id = explode(',', $album_id);
}
$album = new Album();
$albums = $album->where_in('id', $album_id)->get_iterated();
foreach ($albums as $a) {
if ($this->method === 'post') {
$a->save($t);
} else {
$a->delete($t);
}
}
$this->redirect("/text/{$text_id}");
exit;
}
}