<?php

require_once('QueryBuilderAbstract.php');


class QueryDecorator extends QueryBuilderAbstract
{

    public $custom_query;


    public function __construct($custom_query, QueryBuilderInterface $query)
    {
        parent::__construct($query);
        $this->custom_query = $custom_query;
    }


    function getQuery()
    {
        if (parent::getType() == "1") {

            $mainQuery = parent::getQuery();
            return  str_replace('SELECT', $mainQuery, $this->custom_query);

        } else if (parent::getType() == "2") {

            $mainQuery = parent::getQuery();
            return $mainQuery = str_replace('SELECT', parent::getCustomQueryReplacement(), $mainQuery);

        } else {
            return $this->custom_query . parent::getQuery();
        }

    }

    function getType()
    {
        return parent::getType();
    }



}


?>