]> source.dussan.org Git - nextcloud-server.git/commitdiff
add OC_Appconfig::hasKey
authorRobin Appelman <icewind1991@gmail.com>
Sun, 2 Oct 2011 12:30:51 +0000 (14:30 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Sun, 2 Oct 2011 12:30:51 +0000 (14:30 +0200)
lib/appconfig.php

index 392782b2586c99e131697291a56fe45dcee65779..f43ef14173224e5b0c60571ab05bf8278ff5167c 100644 (file)
@@ -100,7 +100,18 @@ class OC_Appconfig{
                        return $default;
                }
        }
-
+       
+       /**
+        * @brief check if a key is set in the appconfig
+        * @param string $app
+        * @param string $key
+        * @return bool
+        */
+       public static function hasKey($app,$key){
+               $exists = self::getKeys( $app );
+               return in_array( $key, $exists );
+       }
+       
        /**
         * @brief sets a value in the appconfig
         * @param $app app
@@ -112,10 +123,7 @@ class OC_Appconfig{
         */
        public static function setValue( $app, $key, $value ){
                // Does the key exist? yes: update. No: insert
-               $exists = self::getKeys( $app );
-
-               // null: does not exist
-               if( !in_array( $key, $exists )){
+               if(! self::hasKey($app,$key)){
                        $query = OC_DB::prepare( 'INSERT INTO *PREFIX*appconfig ( appid, configkey, configvalue ) VALUES( ?, ?, ? )' );
                        $query->execute( array( $app, $key, $value ));
                }