summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2012-05-31 13:06:27 +0200
committerArthur Schiwon <blizzz@owncloud.com>2012-05-31 13:07:49 +0200
commit3b36a9b704339b409c1065e843d33e3b8c8dc213 (patch)
treebeccb7758b67690f0f2310bb21bccd33bd471d24 /apps
parenta33f580db10483f6daa6142923633a3b1d808794 (diff)
downloadnextcloud-server-3b36a9b704339b409c1065e843d33e3b8c8dc213.tar.gz
nextcloud-server-3b36a9b704339b409c1065e843d33e3b8c8dc213.zip
LDAP: make queries compatible also with PostgreSQL
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib_ldap.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php
index 5cd7e0241bf..b900a67ec31 100644
--- a/apps/user_ldap/lib_ldap.php
+++ b/apps/user_ldap/lib_ldap.php
@@ -366,19 +366,24 @@ class OC_LDAP {
$table = self::getMapTable($isUser);
$dn = self::sanitizeDN($dn);
- $sqliteAdjustment = '';
+ $sqlAdjustment = '';
$dbtype = OCP\Config::getSystemValue('dbtype');
- if(($dbtype == 'sqlite') || ($dbtype == 'sqlite3')) {
- $sqliteAdjustment = 'OR';
+ if($dbtype == 'mysql') {
+ $sqlAdjustment = 'FROM dual';
}
$insert = OCP\DB::prepare('
- INSERT '.$sqliteAdjustment.' IGNORE INTO '.$table.'
- (ldap_dn, owncloud_name)
- VALUES (?,?)
+ INSERT INTO '.$table.' (ldap_dn, owncloud_name)
+ SELECT ?,?
+ '.$sqlAdjustment.'
+ WHERE NOT EXISTS (
+ SELECT 1
+ FROM '.$table.'
+ WHERE ldap_dn = ?
+ AND owncloud_name = ? )
');
- $res = $insert->execute(array($dn, $ocname));
+ $res = $insert->execute(array($dn, $ocname, $dn, $ocname));
return !OCP\DB::isError($res);
}