Returns SQL query for data to fetc

@return string
198520
protected function _getQuery()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        // looking for table/view
        $sArtTable = $this->_getViewName('oxarticles');
        $sO2CView = $this->_getViewName('oxobject2category');

        $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 $sArtTable where 1 ";
            $sQAdd .= $myConfig->getConfigParam('blVariantsSelection') ? '' : "and $sArtTable.oxparentid = '' ";
        } else {
            // selected category ?
            if ($sSynchDelId && $sDelId != $sSynchDelId) {
                $sQAdd = " from $sO2CView left join $sArtTable on ";
                $sQAdd .= $myConfig->getConfigParam('blVariantsSelection') ? " ( $sArtTable.oxid=$sO2CView.oxobjectid or $sArtTable.oxparentid=$sO2CView.oxobjectid)" : " $sArtTable.oxid=$sO2CView.oxobjectid ";
                $sQAdd .= "where $sO2CView.oxcatnid = " . $oDb->quote($sDelId);
            } else {
                $sQAdd = ' from oxobject2delivery left join ' . $sArtTable . ' on ' . $sArtTable . '.oxid=oxobject2delivery.oxobjectid ';
                $sQAdd .= 'where oxobject2delivery.oxdeliveryid = ' . $oDb->quote($sDelId) . ' and oxobject2delivery.oxtype = "oxarticles" ';
            }
        }

        if ($sSynchDelId && $sSynchDelId != $sDelId) {
            $sQAdd .= 'and ' . $sArtTable . '.oxid not in ( ';
            $sQAdd .= 'select oxobject2delivery.oxobjectid from oxobject2delivery ';
            $sQAdd .= 'where oxobject2delivery.oxdeliveryid = ' . $oDb->quote($sSynchDelId) . ' and oxobject2delivery.oxtype = "oxarticles" ) ';
        }

        return $sQAdd;
    }
847446
protected function _getQuery()
    {
        $myConfig = Registry::getConfig();
        $oxidId = Registry::getConfig()->getRequestEscapedParameter('oxid');
        $synchId = Registry::getConfig()->getRequestEscapedParameter('synchoxid');
        $db = DatabaseProvider::getDb();
        $this->containerId = Registry::getConfig()->getRequestEscapedParameter('cmpid');

        $articleTable = $this->_getViewName('oxarticles');
        $object2categoryTable = $this->_getViewName('oxobject2category');

        // category selected or not ?
        if (!$oxidId) {
            $outputQuery = " from {$articleTable} where 1 ";
            $outputQuery .= $myConfig->getConfigParam('blVariantsSelection') ? '' : " and {$articleTable}.oxparentid = '' ";
        } else {
            // selected category ?
            if ($synchId && $oxidId != $synchId) {
                $blVariantsSelectionParameter = $myConfig->getConfigParam('blVariantsSelection');
                $trueResponse = " ( {$articleTable}.oxid=$object2categoryTable.oxobjectid " .
                                "or {$articleTable}.oxparentid=$object2categoryTable.oxobjectid )";
                $failResponse = " {$articleTable}.oxid=$object2categoryTable.oxobjectid ";
                $variantSelectionSql = $blVariantsSelectionParameter ? $trueResponse : $failResponse;

                $outputQuery = " from $object2categoryTable left join {$articleTable} on {$variantSelectionSql}" .
                               " where $object2categoryTable.oxcatnid = " . $db->quote($oxidId) . " ";
            } else {
                $outputQuery = " from oxaccessoire2article left join {$articleTable} " .
                               "on oxaccessoire2article.oxobjectid={$articleTable}.oxid " .
                               " where oxaccessoire2article.oxarticlenid = " . $db->quote($oxidId) . " ";
            }
        }

        if ($synchId && $synchId != $oxidId) {
            // performance
            $subSelect = ' select oxaccessoire2article.oxobjectid from oxaccessoire2article ';
            $subSelect .= " where oxaccessoire2article.oxarticlenid = " . $db->quote($synchId) . " ";
            $outputQuery .= " and {$articleTable}.oxid not in ( $subSelect )";
        }

        // skipping self from list
        $sId = ($synchId) ? $synchId : $oxidId;
        $outputQuery .= " and {$articleTable}.oxid != " . $db->quote($sId) . " ";

        // creating AJAX component
        return $outputQuery;
    }
24135
private function getLanguageQuery()
    {
        $languageQuery = $this->dbHandler->createSelectQuery();
        $languageQuery
            ->select(
                $languageQuery->expr->searchedCase(
                    [
                        $languageQuery->expr->lAnd(
                            $languageQuery->expr->eq(
                                $this->dbHandler->quoteColumn('initial_language_id'),
                                ':languageId'
                            ),
                            // wrap bitwise check into another "neq" to provide cross-DBMS compatibility
                            $languageQuery->expr->neq(
                                $languageQuery->expr->bitAnd(
                                    $this->dbHandler->quoteColumn('language_mask'),
                                    ':languageId'
                                ),
                                0
                            )
                        ),
                        $languageQuery->expr->bitOr(
                            ':languageId',
                            1
                        ),
                    ],
                    ':languageId'
                )
            )
            ->from('ezcontentobject')
            ->where(
                $languageQuery->expr->eq(
                    'id',
                    ':contentId'
                )
            );

        return $languageQuery;
    }
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;
    }
782554
protected function getQueryResultRow()
    {
        if ($this->fetchedResults === null) {
            $this->fetchedResults = $this
                ->getQueryResult()
                ->fetchAll();
        }

        return array_shift($this->fetchedResults);
    }
311691
public function getRows()
    {
        $rows = [];
        $wheres = $this->queryBuilder->wheres ?: [];

        foreach ($wheres as $where) {

            // Skip unsupported clauses
            if (!isset($where['column'])) {
                continue;
            }

            // If it doesn't contain the table name assume it's the "FROM" table
            if (strpos($where['column'], '.') === false) {
                $where['column'] = implode('.', [$this->queryBuilder->from, $where['column']]);
            }

            list($table, $column) = $this->splitTableAndColumn($where['column']);

            // Make sure that the where clause applies for the primary key column
            if ($column !== self::PRIMARY_KEY_COLUMN) {
                continue;
            }

            // Initialize a set for the current table
            if (!isset($rows[$table])) {
                $rows[$table] = [];
            }

            // Add the rows to the current table set
            if ($where['type'] === 'Basic') {
                if ($where['operator'] === '=' && is_numeric($where['value'])) {
                    $rows[$table][] = $where['value'];
                }
            }
            else if ($where['type'] === 'In') {
                $rows[$table] += $where['values'];
            }
        }

        return $rows;
    }
1097567
public function getQuery() {
        $query = 'SELECT '.implode(', ', $this->fields)
                .' FROM '.implode(', ', $this->from);
        if (count($this->conditions) > 0) {
            $query = $query.' WHERE '.implode(' AND ', $this->conditions);
        }
        $query = rtrim($query).';';

        return $query;
    }
1251966
protected function GetSQLQueryForQueryRestrictionForActiveFilter()
    {
        $sItemListQuery = parent::GetSQLQueryForQueryRestrictionForActiveFilter();
        $quotedItemTableName = $this->getDatabaseConnection()->quoteIdentifier($this->sItemTableName);
        $sItemListQuery .= " AND $quotedItemTableName.`shop_attribute_id` = '".MySqlLegacySupport::getInstance()->real_escape_string(
                $this->fieldShopAttribute
            )."'";

        return $sItemListQuery;
    }
406630
protected function _getQuery()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        $sCatTable = $this->_getViewName('oxcategories');
        $sDiscountId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');
        $sSynchDiscountId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');

        // category selected or not ?
        if (!$sDiscountId) {
            $sQAdd = " from {$sCatTable} where {$sCatTable}.oxshopid = '" . $myConfig->getShopId() . "' ";
            $sQAdd .= " and {$sCatTable}.oxactive = '1' ";
        } else {
            $sQAdd = " from {$sCatTable} left join oxcategory2attribute " .
                     "on {$sCatTable}.oxid=oxcategory2attribute.oxobjectid " .
                     " where oxcategory2attribute.oxattrid = " . $oDb->quote($sDiscountId) .
                     " and {$sCatTable}.oxshopid = '" . $myConfig->getShopId() . "' " .
                     " and {$sCatTable}.oxactive = '1' ";
        }

        if ($sSynchDiscountId && $sSynchDiscountId != $sDiscountId) {
            $sQAdd .= " and {$sCatTable}.oxid not in ( select {$sCatTable}.oxid " .
                      "from {$sCatTable} left join oxcategory2attribute " .
                      "on {$sCatTable}.oxid=oxcategory2attribute.oxobjectid " .
                      " where oxcategory2attribute.oxattrid = " . $oDb->quote($sSynchDiscountId) .
                      " and {$sCatTable}.oxshopid = '" . $myConfig->getShopId() . "' " .
                      " and {$sCatTable}.oxactive = '1' ) ";
        }

        return $sQAdd;
    }
98020
public function query() {
    $adapter = $this->getAdapter();
    $sql = $this->getSql();
    // always update offset, since it's most likely not contained in the cache id
    $sql = preg_replace('/OFFSET\s+[0-9]+/i', 'OFFSET '.$this->getRawState(Select::OFFSET), $sql);
    $stmt = $adapter->getDriver()->getConnection()->prepare($sql);
    if (self::$logger->isDebugEnabled()) {
      self::$logger->debug("Execute statement: ".$sql);
      self::$logger->debug($this->getParameters(true));
    }
    return $stmt->execute($this->getParameters(true))->getResource();
  }
1019987
public function sql()
    {
        if ($this->active()) {
            if ($this->hasFilters()) {
                $sql = $this->byFilters();
                if ($this->isNegating()) {
                    return $this->operator().' '.$sql;
                }
                return $sql;
            }

            if ($this->hasCondition()) {
                $sql = $this->byCondition();
                if ($this->isNegating()) {
                    return $this->operator().' ('.$sql.')';
                }
                return $sql;
            }

            if ($this->hasFields()) {
                return $this->byPredicate();
            }
        }

        return '';
    }
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);
    }
933587
public function query()
    {
        $stmt = call_user_func_array([$this, 'executeSql'], func_get_args());
        if (ActiveRecord::lastError())
            return false;
        return $stmt->fetchAll();
    }
1365729
protected function _getQuery()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();

        // looking for table/view
        $sArtTable = $this->_getViewName('oxarticles');
        $sO2CView = $this->_getViewName('oxobject2category');
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sSelId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');
        $sSynchSelId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');

        // category selected or not ?
        if (!$sSelId) {
            // performance
            $sQAdd = " from $sArtTable where 1 ";
            $sQAdd .= $myConfig->getConfigParam('blVariantsSelection') ? '' : " and $sArtTable.oxparentid = '' ";
        } else {
            // selected category ?
            if ($sSynchSelId && $sSelId != $sSynchSelId) {
                $sQAdd = " from $sO2CView as oxobject2category left join $sArtTable on ";
                $sQAdd .= $myConfig->getConfigParam('blVariantsSelection') ? " ( $sArtTable.oxid=oxobject2category.oxobjectid or $sArtTable.oxparentid=oxobject2category.oxobjectid ) " : " $sArtTable.oxid=oxobject2category.oxobjectid ";
                $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote($sSelId);
            } else {
                $sQAdd = " from $sArtTable left join oxobject2selectlist on $sArtTable.oxid=oxobject2selectlist.oxobjectid ";
                $sQAdd .= " where oxobject2selectlist.oxselnid = " . $oDb->quote($sSelId);
            }
        }

        if ($sSynchSelId && $sSynchSelId != $sSelId) {
            // performance
            $sQAdd .= " and $sArtTable.oxid not in ( select oxobject2selectlist.oxobjectid from oxobject2selectlist ";
            $sQAdd .= " where oxobject2selectlist.oxselnid = " . $oDb->quote($sSynchSelId) . " ) ";
        }

        return $sQAdd;
    }
494879
public function getQuery()
	{
		if (!$this->query) {
			$this->query = new Query($this->driver, $this->preprocessor);
		}

		return $this->query;
	}
657212
public function getQuery()
    {
        $set = array();
        foreach ($this->set as $key => $value) {
            $set[] = '"'.$key.'" = '.$value;
        }
        
        return 'UPDATE '. $this->table
            . ' SET ' . implode(', ', $set)
            . ' WHERE '. implode(' AND ', $this->where).';';
    }
728951
public function getQuery()
    {
        $query = parent::getQuery();
        if ( $this->hasLimit )
        {
            $max = $this->offset + $this->limit;
            if ( $this->offset > 0 ) 
            {
                $min = $this->offset + 1;
                $query = "SELECT * FROM (SELECT a.*, ROWNUM rn FROM ( {$query} ) a WHERE rownum <= {$max} ) WHERE rn >= {$min}";
            }
            else 
            {
                $query = "SELECT a.* FROM ( {$query} ) a WHERE ROWNUM <= {$max}";
            }            
        }
        return $query;
    }