]> source.dussan.org Git - nextcloud-server.git/commitdiff
improved check in oc_preferences if a key already exists
authorRobin Appelman <icewind1991@gmail.com>
Sun, 19 Jun 2011 20:34:04 +0000 (22:34 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Sun, 19 Jun 2011 20:34:36 +0000 (22:34 +0200)
lib/preferences.php

index 5a9ed39508544136eb1debcfbe6c0b4be1724640..0f4636f683252d3eb608cad08d609f20a9dbb9f1 100644 (file)
@@ -139,10 +139,12 @@ class OC_PREFERENCES{
         */
        public static function setValue( $user, $app, $key, $value ){
                // Check if the key does exist
-               $exists = self::getValue( $user, $app, $key, null );
+               $query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ?' );
+               $values=$query->execute(array($user,$app,$key))->fetchAll();
+               error_log(print_r($values,true));
+               $exists=(count($values)>0);
 
-               // null: does not exist. Insert.
-               if( is_null( $exists )){
+               if( !$exists ){
                        $query = OC_DB::prepare( 'INSERT INTO *PREFIX*preferences ( userid, appid, configkey, configvalue ) VALUES( ?, ?, ?, ? )' );
                        $query->execute( array( $user, $app, $key, $value ));
                }