summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-10-02 14:30:51 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-10-02 14:30:51 +0200
commit88f4f5413a3ca9178d5c015c3250974983f5cd40 (patch)
tree741446f2c891562d21511c3ec877c6dae3a7f753 /lib
parentfef31bc6c78c99a42fcc682f29eeea48293709df (diff)
downloadnextcloud-server-88f4f5413a3ca9178d5c015c3250974983f5cd40.tar.gz
nextcloud-server-88f4f5413a3ca9178d5c015c3250974983f5cd40.zip
add OC_Appconfig::hasKey
Diffstat (limited to 'lib')
-rw-r--r--lib/appconfig.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 392782b2586..f43ef141732 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -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 ));
}