public function execute()
    {
        $this->columns = $this->columns ?: '*';
        $query = "SELECT {$this->columns} FROM $this->table ";

        if ($this->joins) {
            $query .= $this->joins;
        }

        $query .= $this->query;

        if (is_null($this->filename)) {
            $this->filename = '/tmp/file.csv';
        }

        $query .= "
            INTO OUTFILE '{$this->filename}'
            CHARACTER SET utf8
            FIELDS TERMINATED BY ','
            ENCLOSED BY '\"'
            LINES TERMINATED BY '\n'
        ";

        $statement = $this->db->prepare($query);
        $r = $statement->execute();

        if ($this->titles) {
            $file = file_get_contents($this->filename);
            file_put_contents($this->filename, $this->titles . "\n" . $file);
        }

        return $this->filename;
    }