I want to delete more than 1000 rows from the table elgg_object_entity, and the related data at elgg_metadata and elgg_metastrings.
I tried to do a for loop in a plugin file using the fuction delete() but I only can delete 10 at a time.
<?php
include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
admin_gatekeeper();
for ($i=1200; $i<1210; $i++) {
$event = get_entity($i);
$rowsaffected = $event->delete();
}
?>
Do exists a function or option to use instead?
Thanks.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Raúl Ciudad@rciudad
Raúl Ciudad - 0 likes
You must log in to post replies.are you on a cheap shared server hosting ?
elgg is a big boy and needs bigger toys to play with ;-)
if so -- you will have restrictions on server resources such as exec time.
it's definitly not a case of elgg problems b/c of not having the facility
but rather the under-powered server resources.
try running that loop in smaller blocks...
It wasn't a restriction of the server, the problem was that at the range defined at the for loop, there was some inexisting guid. So the code worked this way:
for ($i=21; $i<1420; $i++) {
$event = get_entity($i);
echo $event;
if (!empty($event)) {
$rowsaffected = $event->delete();
}
else {}
}
Thanks.