From ae0ab40b089b5ce57ab1a439123546846f564eed Mon Sep 17 00:00:00 2001 From: Shawn Chen Date: Tue, 4 Dec 2018 13:07:58 +0800 Subject: [PATCH] fix bug on descendant or children failed mysql5.7 Add group_concat aggregrate function to fix bug when get descendant or children query execute failed due to mysql 5.7 default sql_mod=only_full_group_by --- PhpRbac/src/PhpRbac/core/lib/nestedset/full.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PhpRbac/src/PhpRbac/core/lib/nestedset/full.php b/PhpRbac/src/PhpRbac/core/lib/nestedset/full.php index b2a2616..1188a0c 100644 --- a/PhpRbac/src/PhpRbac/core/lib/nestedset/full.php +++ b/PhpRbac/src/PhpRbac/core/lib/nestedset/full.php @@ -227,7 +227,7 @@ function deleteSubtreeConditional($ConditionString,$Rest=null) function descendantsConditional($AbsoluteDepths=false,$ConditionString,$Rest=null) { if (!$AbsoluteDepths) - $DepthConcat="- (sub_tree.innerDepth )"; + $DepthConcat="- (GROUP_CONCAT(sub_tree.innerDepth) )"; $Arguments=func_get_args(); array_shift($Arguments); array_shift($Arguments); //second argument, $AbsoluteDepths @@ -271,7 +271,7 @@ function childrenConditional($ConditionString,$Rest=null) $Arguments=func_get_args(); array_shift($Arguments); $Query=" - SELECT node.*, (COUNT(parent.{$this->id()})-1 - (sub_tree.innerDepth )) AS Depth + SELECT node.*, (COUNT(parent.{$this->id()})-1 - (GROUP_CONCAT(sub_tree.innerDepth) )) AS Depth FROM {$this->table()} AS node, {$this->table()} AS parent, {$this->table()} AS sub_parent, @@ -491,4 +491,4 @@ function editData($FieldValueArray=array(),$ConditionString=null,$Rest=null) } -?> \ No newline at end of file +?>