diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-09-09 21:06:48 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-11-01 15:40:21 +0100 |
commit | 51ec68a6231c577baa0890dbf8b4b91fe9c10ed0 (patch) | |
tree | 25d415bcd92aaf15924c5edf940ed358e3368b16 /apps/files/appinfo | |
parent | 06b42f97886f09ca9527a00e54741fcce511debc (diff) | |
download | nextcloud-server-51ec68a6231c577baa0890dbf8b4b91fe9c10ed0.tar.gz nextcloud-server-51ec68a6231c577baa0890dbf8b4b91fe9c10ed0.zip |
Concatenate string in SQL instead of PHP
Diffstat (limited to 'apps/files/appinfo')
-rw-r--r-- | apps/files/appinfo/update.php | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/files/appinfo/update.php b/apps/files/appinfo/update.php index 3503678e7c7..d8886328d8f 100644 --- a/apps/files/appinfo/update.php +++ b/apps/files/appinfo/update.php @@ -3,17 +3,17 @@ // fix webdav properties,add namespace in front of the property, update for OC4.5 $installedVersion=OCP\Config::getAppValue('files', 'installed_version'); if (version_compare($installedVersion, '1.1.6', '<')) { - $query = OC_DB::prepare( 'SELECT `propertyname`, `propertypath`, `userid` FROM `*PREFIX*properties`' ); - $result = $query->execute(); - $updateQuery = OC_DB::prepare('UPDATE `*PREFIX*properties`' - .' SET `propertyname` = ?' - .' WHERE `userid` = ?' - .' AND `propertypath` = ?'); - while( $row = $result->fetchRow()) { - if ( $row['propertyname'][0] != '{' ) { - $updateQuery->execute(array('{DAV:}' + $row['propertyname'], $row['userid'], $row['propertypath'])); - } + // SQL92 string concatenation is ||, some of the DBMS don't know that + if (OC_Config::getValue('dbtype') === 'mysql') { + $concat = "concat('{DAV:}', `propertyname`)"; + } else if (OC_Config::getValue('dbtype') === 'mssql') { + $concat = "'{DAV:}' + `propertyname`"; + } else { + $concat = "'{DAV:}' || `propertyname`"; } + $query = OC_DB::prepare( "UPDATE `*PREFIX*properties` + SET `propertyname` = $concat + WHERE `propertyname` LIKE '{%'" ); } //update from OC 3 |