本文整理匯總了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;
}