Elgg\Database::deleteData PHP Method

deleteData() public method

Delete data from the database
public deleteData ( string $query, array $params = [] ) : integer
$query string The SQL query to run
$params array Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve']
return integer The number of affected rows
    public function deleteData($query, array $params = [])
    {
        if ($this->logger) {
            $this->logger->info("DB query {$query}");
        }
        $connection = $this->getConnection('write');
        $this->invalidateQueryCache();
        $stmt = $this->executeQuery("{$query}", $connection, $params);
        return (int) $stmt->rowCount();
    }

Usage Example

Example #1
0
 /**
  * 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;
 }
All Usage Examples Of Elgg\Database::deleteData