summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2013-03-29 05:51:41 +0100
committerThomas Tanghus <thomas@tanghus.net>2013-03-29 05:51:41 +0100
commitd838a3b33ff02ec5210695be593626f29dbc65a1 (patch)
treeb3677f59f14e04728b36786dbe2fa9ad72812a2f
parentdf31ee5a903efb288dcb217dc13591a4efd46572 (diff)
downloadnextcloud-server-d838a3b33ff02ec5210695be593626f29dbc65a1.tar.gz
nextcloud-server-d838a3b33ff02ec5210695be593626f29dbc65a1.zip
Allow purging multiple objects from category index table.
-rw-r--r--lib/vcategories.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 2f990c5d2d2..a52c15f0670 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -536,17 +536,22 @@ class OC_VCategories {
/**
* @brief Delete category/object relations from the db
- * @param int $id The id of the object
+ * @param array $ids The ids of the objects
* @param string $type The type of object (event/contact/task/journal).
* Defaults to the type set in the instance
* @returns boolean Returns false on error.
*/
- public function purgeObject($id, $type = null) {
+ public function purgeObjects($ids, $type = null) {
$type = is_null($type) ? $this->type : $type;
+ $updates = array();
try {
- $stmt = OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` '
- . 'WHERE `objid` = ? AND `type`= ?');
- $result = $stmt->execute(array($id, $type));
+ $query = 'DELETE FROM `' . self::RELATION_TABLE . '` ';
+ $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) ';
+ $updates = $ids;
+ $query .= 'AND `type`= ?';
+ $updates[] = $type;
+ $stmt = OCP\DB::prepare($query);
+ $result = $stmt->execute($updates);
if (OC_DB::isError($result)) {
OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
return false;