public static function getData($user,$app="",$key="",$like=false) {
global $CONFIG_DBTABLEPREFIX;
$user=OC_DB::escape($user);
$key=OC_DB::escape($key);
$app=OC_DB::escape($app);
$key="$user::$key";//ugly hack for the sake of keeping database scheme compatibiliy, needs to be replaced with a seperate user field the next time we break db compatibiliy
$compareFunction=($like)?'LIKE':'=';
if($app){
if (!trim($key)) {
$result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata where app='$app' order by `timestamp` desc");
$query = OC_DB::prepare('select app, `key`,value,`timestamp` from *PREFIX*privatedata where app=? order by `timestamp` desc');
$result=$query->execute(array($app))->fetchAll();
} else {
$result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata where app='$app' and `key` $compareFunction '$key' order by `timestamp` desc");
$query = OC_DB::prepare("select app, `key`,value,`timestamp` from *PREFIX*privatedata where app=? and `key` $compareFunction ? order by `timestamp` desc");
$result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata order by `timestamp` desc");
$query = OC_DB::prepare('select app, `key`,value,`timestamp` from *PREFIX*privatedata order by `timestamp` desc');
$result=$query->execute()->fetchAll();
} else {
$result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata where `key` $compareFunction '$key' order by `timestamp` desc");
$query = OC_DB::prepare("select app, `key`,value,`timestamp` from *PREFIX*privatedata where `key` $compareFunction ? order by `timestamp` desc");
$result=$query->execute(array($key))->fetchAll();
}
}
$result=self::trimKeys($result,$user);
@ -545,20 +545,18 @@ class OC_OCS {
* @return bool
*/
public static function setData($user, $app, $key, $value) {
global $CONFIG_DBTABLEPREFIX;
$app=OC_DB::escape($app);
$key=OC_DB::escape($key);
$user=OC_DB::escape($user);
$value=OC_DB::escape($value);
$key="$user::$key";//ugly hack for the sake of keeping database scheme compatibiliy