private function _doQuery($pLimitOne)
    {
        try {
            if (empty($this->_fields)) {
                $fields = '*';
            } else {
                $fields = '`' . implode('`, `', $this->_fields) . '`';
            }

            $query = "
                SELECT
                    $fields
                FROM
                    `" . $this->getDbPrefix() . $this->_dbContainer . "`";

            if ($this->_conditions->count()) {
                $query .= "
                WHERE
                    " . $this->_conditions->getPreparedConditions($this->_dbContainer) . "";
            }

            if (! empty($this->_order)) {
                $query .= $this->_formatOrder();
            }

            if ($pLimitOne) {
                $query .= ' LIMIT 0, 1';
            } else if ($this->_limit !== NULL or $this->_skip !== NULL) {
                $query .= $this->_formatLimit();
            }

            $this->_stm = Agl::app()->getDb()->getConnection()->prepare($query, array(
                PDO::ATTR_CURSOR,
                PDO::CURSOR_SCROLL
            ));

            if (! $this->_stm->execute($this->_conditions->getPreparedValues())) {
                $error = $this->_stm->errorInfo();
                throw new Exception("The select query failed (table '" . $this->getDbPrefix() . $this->_dbContainer . "') with message '" . $error[2] . "'");
            }

            if (Agl::app()->isDebugMode()) {
                Agl::app()->getDb()->incrementCounter();
            }

            return $this;
        } catch (Exception $e) {
            throw new Exception($e);
        }
    }