From ed2d4e421eda0ca87bb916466e2505ca5eff1c55 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Sun, 22 Sep 2013 20:06:10 +0200 Subject: [PATCH] ON DUPLICATE KEY not supported by sqlite --- .../plugins/conf.sql/class.sqlConfDriver.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/src/plugins/conf.sql/class.sqlConfDriver.php b/core/src/plugins/conf.sql/class.sqlConfDriver.php index e1c1d9defd..b04f3ae002 100644 --- a/core/src/plugins/conf.sql/class.sqlConfDriver.php +++ b/core/src/plugins/conf.sql/class.sqlConfDriver.php @@ -513,13 +513,18 @@ function filterUsersByGroup(&$flatUsersList, $baseGroup = "/", $fullTree = false * @param string $groupLabel * @return mixed */ - function createGroup($groupPath, $groupLabel){ - dibi::query( - "INSERT INTO [ajxp_groups]", - array("groupPath" => $groupPath, "groupLabel" => $groupLabel), - "ON DUPLICATE KEY UPDATE %a", - array("groupPath" => $groupPath, "groupLabel" => $groupLabel) - ); + public function createGroup($groupPath, $groupLabel) + { + $test = dibi::query("SELECT groupPath FROM [ajxp_groups] WHERE groupPath = %s", $groupPath); + $res = $test->fetchAll(); + if(count($res)){ + dibi::query("UPDATE [ajxp_groups] SET [groupLabel]=%s WHERE [groupPath]=%s", $groupLabel, $groupPath); + }else{ + dibi::query( + "INSERT INTO [ajxp_groups]", + array("groupPath" => $groupPath, "groupLabel" => $groupLabel) + ); + } } function relabelGroup($groupPath, $groupLabel){