Skip to content

Instantly share code, notes, and snippets.

@Mabahe
Created May 9, 2025 13:05
Show Gist options
  • Save Mabahe/84b1e67e7813c3915b7349c4e3476b7e to your computer and use it in GitHub Desktop.
Save Mabahe/84b1e67e7813c3915b7349c4e3476b7e to your computer and use it in GitHub Desktop.
set @newGroupId := 16;
set @rootPageId := 1041;
set @maxDepth := 99;
UPDATE pages SET perms_groupid = @newGroupId WHERE uid IN (
with recursive children as (
select root.*, 1 as depth
from pages root
where root.uid = @rootPageId
or (root.sys_language_uid > 0 and root.l10n_parent = @rootPageId)
and root.deleted = 0
union all
select parent.*, child.depth + 1 as depth
from pages parent
inner join children child
on (child.sys_language_uid = 0 and parent.pid = child.uid)
where parent.deleted = 0
and child.depth < @maxDepth
)
select uid from children
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment