Returns the SQL query string for current Select SQL Object

@return String The SQL query string
505661
public function getStatement()
    {
        return $this->_fixBlanks(
            trim(
                str_replace(
                    array(
                        '<fields>', '<joinFields>', '<tableName>',
                        '<joins>', '<where>', '<groupBy>',
                        '<orderBy>', '<limit>'
                    ),
                    array(
                        $this->getFields(),
                        $this->getJoinFields(),
                        $this->_sql->getTableName(),
                        $this->getJoins(), 
                        $this->getWhere(),
                        $this->getGroupBy(),
                        $this->getOrderBy(),
                        $this->getLimit()
                    ),
                    $this->_select
                )
            )
        );
    }
404014
protected function _getQuery()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        $sArticleTable = $this->_getViewName('oxarticles');
        $sOCatView = $this->_getViewName('oxobject2category');
        $sOAttrView = $this->_getViewName('oxobject2attribute');

        $sDelId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');
        $sSynchDelId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');

        // category selected or not ?
        if (!$sDelId) {
            // performance
            $sQAdd = " from $sArticleTable where 1 ";
            $sQAdd .= $myConfig->getConfigParam('blVariantsSelection') ? '' : " and $sArticleTable.oxparentid = '' ";
        } elseif ($sSynchDelId && $sDelId != $sSynchDelId) {
            // selected category ?
            $blVariantsSelectionParameter = $myConfig->getConfigParam('blVariantsSelection');
            $sSqlIfTrue = " ( {$sArticleTable}.oxid=oxobject2category.oxobjectid " .
                          "or {$sArticleTable}.oxparentid=oxobject2category.oxobjectid)";
            $sSqlIfFalse = " {$sArticleTable}.oxid=oxobject2category.oxobjectid ";
            $sVariantSelectionSql = $blVariantsSelectionParameter ? $sSqlIfTrue : $sSqlIfFalse;
            $sQAdd = " from {$sOCatView} as oxobject2category left join {$sArticleTable} on {$sVariantSelectionSql}" .
                     " where oxobject2category.oxcatnid = " . $oDb->quote($sDelId) . " ";
        } else {
            $sQAdd = " from {$sOAttrView} left join {$sArticleTable} " .
                     "on {$sArticleTable}.oxid={$sOAttrView}.oxobjectid " .
                     "where {$sOAttrView}.oxattrid = " . $oDb->quote($sDelId) .
                     " and {$sArticleTable}.oxid is not null ";
        }

        if ($sSynchDelId && $sSynchDelId != $sDelId) {
            $sQAdd .= " and {$sArticleTable}.oxid not in ( select {$sOAttrView}.oxobjectid from {$sOAttrView} " .
                      "where {$sOAttrView}.oxattrid = " . $oDb->quote($sSynchDelId) . " ) ";
        }

        return $sQAdd;
    }
475553
public function getQuery()
    {
        if (count($this->parts['select']) === 0) {
            throw new QueryException('Missing "select" parts to generate query.');
        }

        $sql = 'SELECT ';

        if ($this->distinct) {
            $sql .= 'DISTINCT ';
        }

        $sql .= implode(', ', $this->parts['select']) . ' FROM';

        if (count($this->parts['from']) === 0) {
            throw new QueryException('Missing "from" parts to generate query.');
        }

        $renderedFromBefore = false;

        foreach ($this->parts['from'] as $fromPart) {
            if ($fromPart['type'] === 'FROM') {
                if ($renderedFromBefore === true) {
                    $sql .= ',';
                }

                $sql .= ' ' . $fromPart['table'];
                $renderedFromBefore = true;
            } else {
                $sql .= ' ' . $fromPart['type'] . ' JOIN ' . $fromPart['table'];

                if ($fromPart['condition']) {
                    $sql .= ' ON ' . $fromPart['condition'];
                }
            }
        }

        if (count($this->parts['where']) > 0) {
            $sql .= ' WHERE ' . implode(' AND ', $this->parts['where']);
        }

        if (count($this->parts['groupBy']) > 0) {
            $sql .= ' GROUP BY ' . implode(', ', $this->parts['groupBy']);
        }

        if (count($this->parts['having']) > 0) {
            $sql .= ' HAVING ' . implode(' AND ', $this->parts['having']);
        }

        if (count($this->parts['orderBy']) > 0) {
            $sql .= ' ORDER BY ' . implode(', ', $this->parts['orderBy']);
        }

        if ($this->limit || $this->offset) {
            $sql = $this->connection->getDatabasePlatform()->modifyLimitQuery(
                $sql,
                $this->limit,
                $this->offset
            );
        }

        return $sql;
    }
372192
public static function getQueryString()
    {
        $querystringsDefault = explode('&', $_SERVER['QUERY_STRING']);
        $querystrings = array();

        foreach ($querystringsDefault as $querystring) {
            $querystring = explode('=', $querystring);
            $querystrings[$querystring[0]] = isset($querystring[1]) ? $querystring[1] : null;
        }

        return $querystrings;
    }
524358
public function getSql()
    {
        $compileFunction = $this->getCompileFunction();
        $grammar = $this->queryBuilder->getGrammar();

        $sql = call_user_func_array([$grammar, $compileFunction], [
            'builder'  => $this->queryBuilder,
            'values'   => $this->values,
            'sequence' => '',
        ]);

        // For some DBMS like SQLite Laravel issues two queries as an array instead of one string
        // This is seriously not ok, but anyway...
        if (is_array($sql)) {
            $sql = implode('; ', array_keys($sql));
        }

        return $sql;
    }
1018921
public function getSql()
    {
        $table = $this->table;

        if ($this->hasTable($table)) {
            $this->isChange = true;
        }

        $columnSql = $this->getCreateDefinition();

        if ($this->isChange) {
            $sql = "ALTER TABLE $table" . $columnSql;
        } else {
            $sql = "CREATE TABLE $table ($columnSql)";
            $sql .= $this->getTableOptionSql();
        }

        return $sql;
    }
294991
public function getQueryString()
    {
        $qs = Request::normalizeQueryString($this->requestStack->getCurrentRequest()->server->get('QUERY_STRING'));

        return '' === $qs ? null : $qs;
    }
319919
public function getValue()
    {
        $sql = '('.$this->query->toSql().')';

        if ($this->alias) {
            $alias = $this->query->getGrammar()->wrapTable($this->alias);

            $sql .= ' as '.$alias;
        }

        return $sql;
    }
576041
protected function _getQuery()
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');
        $sSynchId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');

        $sPayTable = $this->_getViewName('oxpayments');

        // category selected or not ?
        if (!$sId) {
            $sQAdd = " from $sPayTable where 1 ";
        } else {
            $sQAdd = " from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = " . $oDb->quote($sId);
            $sQAdd .= " and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ";
        }

        if ($sSynchId && $sSynchId != $sId) {
            $sQAdd .= "and $sPayTable.oxid not in ( select $sPayTable.oxid from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = " . $oDb->quote($sSynchId);
            $sQAdd .= "and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ) ";
        }

        return $sQAdd;
    }
812414
protected function get_searchsql() {
        global $DB;

        $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
        $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
        $params = array(
            'contextlevel' => CONTEXT_COURSE,
            'fullnamesearch' => '%'.$this->get_search().'%',
            'shortnamesearch' => '%'.$this->get_search().'%'
        );

        $select     = " SELECT c.id, c.fullname, c.shortname, c.visible, c.sortorder ";
        $from       = " FROM {course} c ";
        $where      = " WHERE (".$DB->sql_like('c.fullname', ':fullnamesearch', false)." OR ".
            $DB->sql_like('c.shortname', ':shortnamesearch', false).")";
        $orderby    = " ORDER BY c.sortorder";

        if ($this->currentcourseid !== null && !$this->includecurrentcourse) {
            $where .= " AND c.id <> :currentcourseid";
            $params['currentcourseid'] = $this->currentcourseid;
        }

        return array($select.$ctxselect.$from.$ctxjoin.$where.$orderby, $params);
    }
113969
protected function get_searchsql() {
        global $DB;

        $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
        $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
        $params = array(
            'contextlevel' => CONTEXT_COURSECAT,
            'namesearch' => '%'.$this->get_search().'%',
        );

        $select     = " SELECT c.id, c.name, c.visible, c.sortorder, c.description, c.descriptionformat ";
        $from       = " FROM {course_categories} c ";
        $where      = " WHERE ".$DB->sql_like('c.name', ':namesearch', false);
        $orderby    = " ORDER BY c.sortorder";

        return array($select.$ctxselect.$from.$ctxjoin.$where.$orderby, $params);
    }
697313
public function getQuery()
    {
        $sql = $this->setQuery;
        $sql .= $this->getWhere();
        $sql .= $this->getGroupBy();
        $sql .= $this->getOrderBy();
        $sql .= $this->getHaving();
        $sql .= $this->getLimit();

        $this->setQuery = null;
        $this->setWhere = null;
        $this->setHaving = null;
        $this->setOrderBy = null;
        $this->setGroupBy = null;
        $this->setLimit = null;

        return str_replace('  ', ' ', $sql);
    }
1234402
protected function _getQuery()
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $oConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $sId = $oConfig->getRequestParameter('oxid');
        $sSynchId = $oConfig->getRequestParameter('synchoxid');

        $sCategoryTable = $this->_getViewName('oxcategories');

        // category selected or not ?
        if (!$sId) {
            $sQAdd = " from {$sCategoryTable}";
        } else {
            $sQAdd = " from oxobject2discount, {$sCategoryTable} " .
                     "where {$sCategoryTable}.oxid=oxobject2discount.oxobjectid " .
                     " and oxobject2discount.oxdiscountid = " . $oDb->quote($sId) .
                     " and oxobject2discount.oxtype = 'oxcategories' ";
        }

        if ($sSynchId && $sSynchId != $sId) {
            // performance
            $sSubSelect = " select {$sCategoryTable}.oxid from oxobject2discount, {$sCategoryTable} " .
                          "where {$sCategoryTable}.oxid=oxobject2discount.oxobjectid " .
                          " and oxobject2discount.oxdiscountid = " . $oDb->quote($sSynchId) .
                          " and oxobject2discount.oxtype = 'oxcategories' ";
            if (stristr($sQAdd, 'where') === false) {
                $sQAdd .= ' where ';
            } else {
                $sQAdd .= ' and ';
            }
            $sQAdd .= " {$sCategoryTable}.oxid not in ( $sSubSelect ) ";
        }

        return $sQAdd;
    }
219699
protected function _getQuery()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();

        $sArticleTable = $this->_getViewName('oxarticles');
        $sO2CView = $this->_getViewName('oxobject2category');

        $sOxid = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');
        $sSynchOxid = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        // category selected or not ?
        if (!$sOxid && $sSynchOxid) {
            // dodger performance
            $sQAdd = ' from ' . $sArticleTable . ' where 1 ';
        } else {
            // copied from oxadminview
            $sJoin = " {$sArticleTable}.oxid={$sO2CView}.oxobjectid ";

            $sSubSelect = '';
            if ($sSynchOxid && $sOxid != $sSynchOxid) {
                $sSubSelect = ' and ' . $sArticleTable . '.oxid not in ( ';
                $sSubSelect .= "select $sArticleTable.oxid from $sO2CView left join $sArticleTable ";
                $sSubSelect .= "on $sJoin where $sO2CView.oxcatnid =  " . $oDb->quote($sSynchOxid) . " ";
                $sSubSelect .= 'and ' . $sArticleTable . '.oxid is not null ) ';
            }

            $sQAdd = " from $sO2CView join $sArticleTable ";
            $sQAdd .= " on $sJoin where $sO2CView.oxcatnid = " . $oDb->quote($sOxid);
            $sQAdd .= " and $sArticleTable.oxid is not null $sSubSelect ";
        }

        return $sQAdd;
    }
320580
protected function sql()
    {
        if ( null === $this->sql )
        {
            $this->sql = new Sql(
                $this->getDbAdapter(),
                $this->getTableInSchema( 'settings' )
            );
        }

        return $this->sql;
    }
301365
public function getSelectName() : ?string
    {
        if (null !== $this->select_name) {
            return $this->select_name . ' as ' . $this->getDBName();
        }
        if (null !== $this->db_name) {
            return $this->db_name;
        }
        return $this->attributes['name'];
    }
570246
public function getQueryString()
    {
        $query_string = '';
        if (count($this->query_string) > 0) {
            $query_string .= http_build_query($this->query_string);
        }
        if ($this->method != 'POST') {
            if (count($this->data) > 0) {
                $query_string .= http_build_query($this->data);
            }
        }
        if (mb_strlen($query_string) > 0) {
            $query_string = (mb_strpos($this->url, '?') ? '&' : '?') . $query_string;
        }

        return $query_string;
    }