本文整理汇总了PHP中Album::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::query方法的具体用法?PHP Album::query怎么用?PHP Album::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Album
function repair_tree()
{
$query = <<<Q
SELECT *
FROM {$this->table} mto
WHERE EXISTS
(
SELECT 1
FROM {$this->table} mti
WHERE mti.left_id = mto.left_id
AND mti.deleted = mto.deleted
AND mti.visibility = mto.visibility
LIMIT 1, 1
)
ORDER BY left_id ASC, album_type ASC, id ASC
LIMIT 1
Q;
$fresh = new Album();
$dupes = $fresh->query($query);
if (count($dupes->all) < 1) {
return true;
}
$keep = $dupes->all[0];
$diff = $keep->right_id - $keep->left_id + 1;
$this->where('visibility', $keep->visibility)->where('deleted', $keep->deleted)->where('right_id >=', $keep->right_id)->where('id !=', $keep->id)->update(array('right_id' => "right_id + {$diff}"), false);
$this->where('visibility', $keep->visibility)->where('deleted', $keep->deleted)->where('left_id >=', $keep->left_id)->where('id !=', $keep->id)->update(array('left_id' => "left_id + {$diff}"), false);
return $this->repair_tree();
}
示例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();
}