Airship\Engine\Database::delete PHP Method

delete() public method

Delete rows in a database table.
public delete ( string $table, array $conditions = [] ) : mixed
$table string - table name
$conditions array - WHERE clause
return mixed
    public function delete(string $table, array $conditions = [])
    {
        if (empty($conditions)) {
            // Don't allow foot-bullets
            return null;
        }
        $queryString = "DELETE FROM " . $this->escapeIdentifier($table) . " WHERE ";
        // Simple array for joining the strings together
        $arr = [];
        $params = [];
        foreach ($conditions as $i => $v) {
            $i = $this->escapeIdentifier($i);
            if ($v === null) {
                $arr[] = " {$i} IS NULL ";
            } elseif ($v === true) {
                $arr[] = " {$i} = TRUE ";
            } elseif ($v === false) {
                $arr[] = " {$i} = FALSE ";
            } elseif (\is_array($v)) {
                throw new \TypeError(\trk('errors.database.array_passed'));
            } else {
                $arr[] = " {$i} = ? ";
                $params[] = $v;
            }
        }
        $queryString .= \implode(' AND ', $arr);
        return $this->safeQuery($queryString, $params);
    }