public function remove(
        $table = null,
        SqlInterface $database = null,
        $primary = null
    ) {
        //if no table
        if (is_null($table)) {
            //if no default table either
            if (!$this->table) {
                //throw error
                throw SqlException::forTableNotSet();
            }

            $table = $this->table;
        }

        //if no database
        if (is_null($database)) {
            //and no default database
            if (!$this->database) {
                throw SqlException::forDatabaseNotSet();
            }

            $database = $this->database;
        }

        //get the meta data and valid columns
        $meta = $this->getMeta($table, $database);
        $data = $this->getValidColumns(array_keys($meta[self::COLUMNS]));

        if (is_null($primary)) {
            $primary = $meta[self::PRIMARY];
        }

        if (is_string($primary)) {
            $primary = [$primary];
        }

        $filter = [];
        //for each primary key
        foreach ($primary as $column) {
            //if the primary is not set
            if (!isset($data[$column])) {
                //we can't do a remove
                //do nothing more
                return $this;
            }

            //add the condition to the filter
            $filter[] = [$column.'=%s', $data[$column]];
        }

        //we delete it
        $database->deleteRows($table, $filter);

        return $this;
    }