public function assemble()
    {
        $queryString = array();

        $queryString[] = $this->query['type'];

        // Select query
        if ($this->query['type'] == "SELECT"
        or  $this->query['type'] == "SELECT DISTINCT") {
            // Build columns to select
            $queryString[] = $this->buildSelectColumns();

            // From
            $queryString[] = "FROM `{$this->query['table']}`";

            // Joins
            if (array_key_exists('joins', $this->query)) {
                $queryString[] = $this->buildJoins();
            }

            // Where
            $queryString[] = $this->buildWhere();

            // Custom SQL
            if (array_key_exists('sql', $this->query)) {
                $queryString[] = $this->query['sql'];
            }

            // Order by
            if (array_key_exists('order_by', $this->query)) {
                $queryString[] = "ORDER BY " . implode(", ", $this->query['order_by']);
            }
        }
        // Insert
        elseif ($this->query['type'] == "INSERT INTO") {
            // Table
            $queryString[] = "`{$this->query['table']}`";

            // Get the columns and values
            $columns = $values = array();
            foreach ($this->query['data'] as $column => $value) {
                $columns[] = $this->columnName($column);
                $values[] = $this->processValue($value);
            }

            // Add columns and values to query
            $queryString[] = "(" . implode(',', $columns) . ")";
            $queryString[] = "VALUES (" . implode(',', $values) . ")";
        }
        // Update
        elseif ($this->query['type'] == "UPDATE") {
            // Table
            $queryString[] = "`{$this->query['table']}`";

            // Set values
            $values = array();
            foreach ($this->query['data'] as $column => $value) {
                // Process column name
                $column = $this->columnName($column);

                // Add value to bind queue
                $valueBindKey = "new_" . str_replace(array('.', '`'), array('_', ''), $column);
                $this->valuesToBind[$valueBindKey] = $value;

                // Add to values
                $values[] = $column . " = :{$valueBindKey}";
            }

            // Add values to query
            $queryString[] = "SET " . implode(", ", $values);

            $queryString[] = $this->buildWhere();
        }
        // Delete from
        elseif ($this->query['type'] == "DELETE") {
            // Table
            $queryString[] = "FROM `{$this->query['table']}`";

            // Where
            $queryString[] = $this->buildWhere();
        }

        return implode(" ", str_replace("{prefix}", $this->prefix, $queryString));
    }