selectQuery

@return string
183727
public static function selectQuery($tableName, $fields, $data, $condition, $connection)
    {
        $query = "";
        $columnName = "";
        
        try
        {
            $arraySize = count($data);
            if( $arraySize > 1 && $condition == NULL)
            {
                $query = "Please Supply the condition";
            }
            else
            {
                if ($condition === 'AND' || $condition === 'OR' || $condition === NULL) {
                    $columnName = self::whereAndClause($tableName, $data, $condition);
                } elseif ($condition === 'LIKE') {
                    $columnName = self::whereLikeClause($tableName, $data, $condition);
                } 
                $query =  "SELECT $fields FROM $tableName WHERE $columnName";
            }
        } catch (PDOException $e) {
            $query = $e->getMessage();
        }

        return $query;
    }
883664
protected function getTable()
	{
		$table = parent::getTable();

		if ($table instanceof SelectQuery) return "(" . $table->get(false) . ")";

		return $table;
	}
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;
    }
59218
private function parseSelectQuery()
    {
        // Parse select ?
        $selectSql = Column::generateQueryString($this->query->select);

        // Parse table
        $fromSql = Table::generateQueryString($this->query->table);

        $whereSql = null;
        $whereBind = array();


        $sql = [
            'select' => $selectSql,
            'from' => $fromSql,
            'where' => $whereSql
            // TODO: Add other parts.
        ];

        $this->bind = array_merge(
            $this->bind,
            $whereBind
        );

        $this->sql = $this->combineSelectQuery($sql);
    }
970161
final public function getQuery()
    {
        if (null === $this->query) {

            $this->query = $this->buildQuery();

            // Apply conditions.
            foreach ($this->conditions as $statement => $value) {
                $this->applyOperator($this->query, $statement, $value);
            }

            $limit = $this->getLimit();

            if (CursorInterface::LIMIT_NONE !== $limit) {
                $this->query->range($this->getOffset(), $limit);
            }
        }

        return $this->query;
    }
247460
protected function getSelect()
    {
        $html = '<select>';

        if (is_array($this->window['all'])) {
            $html .= $this->getOptionLinks($this->window['all']);
        }

        $html .= '</select>';

        return $html;
    }
534735
protected function createSelectQuery()
    {
        $query = $this->handler->createSelectQuery();
        $query->select(
            $this->handler->quoteColumn(self::COLUMN_ID),
            $this->handler->quoteColumn(self::COLUMN_URL),
            $this->handler->quoteColumn(self::COLUMN_ORIGINAL_URL_MD5),
            $this->handler->quoteColumn(self::COLUMN_IS_VALID),
            $this->handler->quoteColumn(self::COLUMN_LAST_CHECKED),
            $this->handler->quoteColumn(self::COLUMN_CREATED),
            $this->handler->quoteColumn(self::COLUMN_MODIFIED)
        )->from(
            $this->handler->quoteTable(self::URL_TABLE)
        );

        return $query;
    }
1190604
public function union(SelectQuery $query)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->union($query);

        return $instance;
    }
27702
public function getQuery()
    {

        $strings = $this->string;
        $query = $this->buildQuery($this->getPattern($this->getChieldPattern()), $strings);

        return $query;
    }
1370198
protected function _getQuery()
    {
        $sSLViewName = $this->_getViewName('oxselectlist');
        $sArtViewName = $this->_getViewName('oxarticles');
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

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

        $sOxid = ($sArtId) ? $sArtId : $sSynchArtId;
        $sQ = "select oxparentid from {$sArtViewName} where oxid = " . $oDb->quote($sOxid) . " and oxparentid != '' ";
        $sQ .= "and (select count(oxobjectid) from oxobject2selectlist " .
               "where oxobjectid = " . $oDb->quote($sOxid) . ") = 0";
        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804 and ESDEV-3822).
        $sParentId = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster()->getOne($sQ);

        // all selectlists article is in
        $sQAdd = " from oxobject2selectlist left join {$sSLViewName} " .
                 "on {$sSLViewName}.oxid=oxobject2selectlist.oxselnid  " .
                 "where oxobject2selectlist.oxobjectid = " . $oDb->quote($sOxid) . " ";
        if ($sParentId) {
            $sQAdd .= "or oxobject2selectlist.oxobjectid = " . $oDb->quote($sParentId) . " ";
        }
        // all not assigned selectlists
        if ($sSynchArtId) {
            $sQAdd = " from {$sSLViewName}  " .
                     "where {$sSLViewName}.oxid not in ( select oxobject2selectlist.oxselnid {$sQAdd} ) ";
        }

        return $sQAdd;
    }
858670
public function getQuery()
    {
        if ($this->query === null) {
            $string = parse_url($this->link, PHP_URL_QUERY);

            parse_str($string, $this->query);
        }

        return $this->query;
    }
1047378
public static function select()
    {
        try {
            self::init();
            $columns = func_get_args();
            $query = 'SELECT ' . implode(', ', $columns) . ' FROM ' . self::$modelTable;
            return new QueryBuilder(self::$connect, $query);

        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
        }
    }
1079738
public function select()
    {
        $query     = 'SELECT ' . $this->getQueryFields() . ' FROM ' . $this->getTable() . ' ' . $this->getQueryWhere() . ' ' . $this->getQueryOrderBy() . ' ' . $this->getQueryLimit();
        $statement = $this->db->prepare($query);
        $statement->execute($this->binds);

        $this->clear();

        $collection = array();

        while (false !== ($row = $statement->fetchObject())) {
            $collection[] = $this->newDataInstance($row, true);
        }

        return $collection;
    }
251498
public function select($columns = "*") : QueryBuilder
    {
        $this->_query[] = "SELECT";

        //Parse column(s)
        if(is_array($columns)) {
            $select_columns = "";

            $size = sizeof($columns);
            for($i = 0; $i < $size; $i++) {
                if($i > 0) {
                    $select_columns .= ', ';
                }

                $select_columns .= '`'. $this->sanitize((string)$columns[$i]) .'`';
            }

            $this->_query[] = $select_columns;

            return $this;
        }

        $select_columns = "*";
        if(
            !empty($columns) &&
            $columns !== "*"
        ) {
            $select_columns = '`'. $this->sanitize((string)$columns) .'`';
        }

        $this->_query[] = $select_columns;

        return $this;
    }
404595
public function getQuery()
    {
        // Convert the query string to a query object if not already done.
        if (!$this->query instanceof Query) {
            $this->query = $this->query === null
                ? new Query()
                : Query::fromString($this->query);
        }

        return $this->query;
    }
1149215
public function getSearchQuery()
    {
        $searchQuery = '';
        if (!empty(get_search_query())) {
            $searchQuery = get_search_query();
        } elseif (!empty($_GET['s'])) {
            $searchQuery = esc_attr($_GET['s']);
        }

        return $searchQuery;
    }
1104051
public function getQuery(): string
    {
        $sql = $this->getSql();

        $sql = str_replace(['%', '?'], ['%%', '"%s"'], $sql);

        // replace mask by data
        return vsprintf($sql, $this->getParams());
    }