/** * Removes a config setting. * * @param string $name The name of the field. * * @return bool Success or failure */ function remove($name) { $name = trim($name); if (isset($this->CONFIG->{$name})) { unset($this->CONFIG->{$name}); } $query = "\n\t\t\tDELETE FROM {$this->CONFIG->dbprefix}config\n\t\t\tWHERE name = :name\n\t\t"; $params = [':name' => $name]; $this->boot->invalidateCache(); return $this->db->deleteData($query, $params) !== false; }
/** * Removes all relationships originating from a particular entity * * @param int $guid GUID of the subject or target entity (see $inverse) * @param string $relationship Type of the relationship (optional, default is all relationships) * @param bool $inverse_relationship Is $guid the target of the deleted relationships? By default, $guid is the * subject of the relationships. * @param string $type The type of entity related to $guid (defaults to all) * * @return true */ public function removeAll($guid, $relationship = "", $inverse_relationship = false, $type = '') { $guid = (int) $guid; if (!empty($relationship)) { $relationship = $this->db->sanitizeString($relationship); $where = "AND er.relationship = '{$relationship}'"; } else { $where = ""; } if (!empty($type)) { $type = $this->db->sanitizeString($type); if (!$inverse_relationship) { $join = "JOIN {$this->db->getTablePrefix()}entities e ON e.guid = er.guid_two"; } else { $join = "JOIN {$this->db->getTablePrefix()}entities e ON e.guid = er.guid_one"; $where .= " AND "; } $where .= " AND e.type = '{$type}'"; } else { $join = ""; } $guid_col = $inverse_relationship ? "guid_two" : "guid_one"; $this->db->deleteData("\n\t\t\tDELETE er FROM {$this->db->getTablePrefix()}entity_relationships AS er\n\t\t\t{$join}\n\t\t\tWHERE {$guid_col} = {$guid}\n\t\t\t{$where}\n\t\t"); return true; }
/** * Removes all relationships originating from a particular entity * * @param int $guid GUID of the subject or target entity (see $inverse) * @param string $relationship Type of the relationship (optional, default is all relationships) * @param bool $inverse_relationship Is $guid the target of the deleted relationships? By default, $guid is the * subject of the relationships. * @param string $type The type of entity related to $guid (defaults to all) * * @return true */ public function removeAll($guid, $relationship = "", $inverse_relationship = false, $type = '') { $guid = (int) $guid; $params = []; if (!empty($relationship)) { $where = "AND er.relationship = :relationship"; $params[':relationship'] = $relationship; } else { $where = ""; } if (!empty($type)) { if (!$inverse_relationship) { $join = "JOIN {$this->db->prefix}entities e ON e.guid = er.guid_two"; } else { $join = "JOIN {$this->db->prefix}entities e ON e.guid = er.guid_one"; $where .= " AND "; } $where .= " AND e.type = :type"; $params[':type'] = $type; } else { $join = ""; } $guid_col = $inverse_relationship ? "guid_two" : "guid_one"; $this->db->deleteData("\n\t\t\tDELETE er FROM {$this->db->prefix}entity_relationships AS er\n\t\t\t{$join}\n\t\t\tWHERE {$guid_col} = {$guid}\n\t\t\t{$where}\n\t\t", $params); return true; }
/** * Deletes all private settings for an entity * * @param int $entity_guid The Entity GUID * @return bool */ public function removeAllForEntity($entity_guid) { $this->cache->clear($entity_guid); _elgg_services()->boot->invalidateCache(); $query = "\n\t\t\tDELETE FROM {$this->table}\n\t\t\tWHERE entity_guid = :entity_guid\n\t\t"; $params = [':entity_guid' => (int) $entity_guid]; return $this->db->deleteData($query, $params); }
/** * Deletes all private settings for an entity * * @param int $entity_guid The Entity GUID * @return bool */ function removeAllForEntity($entity_guid) { $entity_guid = (int) $entity_guid; $entity = $this->entities->get($entity_guid); if (!$entity instanceof \ElggEntity) { return false; } return $this->db->deleteData("DELETE FROM {$this->table}\n\t\t\tWHERE entity_guid = {$entity_guid}"); }
/** * Removes a registered \ElggEntity type, subtype, and classname. * * @warning You do not want to use this function. If you want to unregister * a class for a subtype, use update_subtype(). Using this function will * permanently orphan all the objects created with the specified subtype. * * @param string $type Type * @param string $subtype Subtype * * @return bool * @see add_subtype() * @see update_subtype() */ public function remove($type, $subtype) { $sql = "\n\t\t\tDELETE FROM {$this->db->prefix}entity_subtypes\n\t\t\tWHERE type = :type AND subtype = :subtype\n\t\t"; $params = [':type' => $type, ':subtype' => $subtype]; if (!$this->db->deleteData($sql, $params)) { return false; } $this->invalidateCache(); return true; }
/** * {@inheritDoc} */ public function gc($max_lifetime) { $life = time() - $max_lifetime; $query = "DELETE FROM {$this->db->getTablePrefix()}users_sessions WHERE ts < '{$life}'"; return (bool) $this->db->deleteData($query); }
/** * Unlocks mutex * * @param string $namespace Namespace to use for the database table * @return void */ public function unlock($namespace) { $this->assertNamespace($namespace); $this->db->deleteData("DROP TABLE {$this->db->getTablePrefix()}{$namespace}_lock"); $this->logger->notice("Mutex unlocked for {$namespace}."); }
/** * {@inheritdoc} */ public function deleteData($query, array $params = []) { return $this->db->deleteData($query, $params); }