本文整理汇总了PHP中phpbb\db\driver\driver_interface::sql_case方法的典型用法代码示例。如果您正苦于以下问题:PHP driver_interface::sql_case方法的具体用法?PHP driver_interface::sql_case怎么用?PHP driver_interface::sql_case使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\db\driver\driver_interface
的用法示例。
在下文中一共展示了driver_interface::sql_case方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare_adding_subset
/**
* Prepare adding a subset to the nested set
*
* @param array $subset_items Subset of items to add
* @param array $new_parent Item containing the right bound of the new parent
* @return int New right id of the parent item
*/
protected function prepare_adding_subset(array $subset_items, array $new_parent)
{
$diff = sizeof($subset_items) * 2;
$sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
$set_left_id = $this->db->sql_case($this->column_left_id . ' > ' . (int) $new_parent[$this->column_right_id], $this->column_left_id . ' + ' . $diff, $this->column_left_id);
$set_right_id = $this->db->sql_case($this->column_right_id . ' >= ' . (int) $new_parent[$this->column_right_id], $this->column_right_id . ' + ' . $diff, $this->column_right_id);
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
' . $this->column_right_id . ' = ' . $set_right_id . '
WHERE ' . $sql_not_subset_items . '
' . $this->get_sql_where('AND');
$this->db->sql_query($sql);
return $new_parent[$this->column_right_id] + $diff;
}