protected function createPdoStatement($query, $pdo = null)
    {
        if (is_null($pdo)) {
            $pdo = $this->getPdo();
        }

        $grammar = $this->getQueryGrammar();

        $query = preg_replace_callback('#\{(.*?)\}#', function ($matches) use ($grammar)
        {
            $value = $matches[1];

            return $grammar->wrap($value);

        }, $query);

        return $pdo->prepare($query);
    }