From a84c649d391a13218343bb5a934f26cbb6568f0a Mon Sep 17 00:00:00 2001 From: icewing Date: Fri, 25 Apr 2008 17:53:05 +0000 Subject: Marcus Povey * Crude deleteall method added git-svn-id: https://code.elgg.org/elgg/trunk@539 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'engine/lib/entities.php') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 21ef3d595..b83b9f4b5 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -807,7 +807,7 @@ $query .= " (access_id in {$access} or (access_id = 0 and owner_guid = {$_SESSION['id']}))"; // Add access controls if (!$count) { $query .= " order by $order_by"; - $query .= " limit $offset, $limit"; // Add order and limit + if ($limit) $query .= " limit $offset, $limit"; // Add order and limit $dt = get_data($query, "entity_row_to_elggstar"); return $dt; } else { @@ -841,6 +841,25 @@ return false; } + + /** + * Delete multiple entities that match a given query. + * This function itterates through and calls delete_entity on each one, this is somewhat inefficient but lets + * the 'delete' even be called for each entity. + * + * @param string $type The type of entity (eg "user", "object" etc) + * @param string $subtype The arbitrary subtype of the entity + * @param int $owner_guid The GUID of the owning user + */ + function delete_entities($type = "", $subtype = "", $owner_guid = 0) + { + $entities = get_entities($type, $subtype, $owner_guid, "time_created desc", 0); + + foreach ($entities as $entity) + delete_entity($entity->guid); + + return true; + } /** * Handler called by trigger_plugin_hook on the "export" event. -- cgit v1.2.3