diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php index 261a8d75..c6246d53 100644 --- a/src/API/EntityAPI.php +++ b/src/API/EntityAPI.php @@ -118,6 +118,8 @@ class EntityAPI{ public function remove($eid){ if(isset($this->server->entities[$eid])){ + $this->server->query("DELETE FROM entities WHERE EID = ".$eid.";"); + $this->server->api->dhandle("entity.remove", $this->server->entities[$eid]); $this->server->entities[$eid]->close(); unset($this->server->entities[$eid]); } diff --git a/src/classes/Entity.class.php b/src/classes/Entity.class.php index 7c402ce2..d6c49814 100644 --- a/src/classes/Entity.class.php +++ b/src/classes/Entity.class.php @@ -163,10 +163,8 @@ class Entity extends stdClass{ public function close(){ if($this->closed === false){ - $this->server->query("DELETE FROM entities WHERE EID = ".$this->eid.";"); - $this->server->api->dhandle("entity.remove", $this); + $this->server->api->entity->remove($this->eid); $this->closed = true; - $this->__destruct(); } }