$display_order = [$this->data[‘user_id‘]=>‘1‘, $this->token_info[‘id‘]=>‘0‘]; $params = array_keys($display_order); $place_holders = implode(‘,‘, array_fill(0, count($params), ‘?‘)); $sql = "UPDATE home_users SET is_admin = CASE user_id "; foreach ($display_order as $user_id => $is_admin) { $sql .= sprintf("WHEN %d THEN ‘%s‘ ", $user_id, $is_admin); } $sql .= "END WHERE user_id IN ($place_holders) AND home_id = ?"; $params[] = $this->data[‘home_id‘]; Model::home_users()->executeBySql($sql,$params);
时间: 2024-11-05 11:35:59