Skip to content
Snippets Groups Projects
Commit d838a3b3 authored by Thomas Tanghus's avatar Thomas Tanghus
Browse files

Allow purging multiple objects from category index table.

parent df31ee5a
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment