Returns array with sql code and parameters returning all ids
of users who meet this particular criterion.

@return array list($join, $where, $params)
961757
public function get_completed_criteria_sql() {
        $join = '';
        $where = '';
        $params = array();

        if ($this->method == BADGE_CRITERIA_AGGREGATION_ANY) {
            // User has received ANY of the required badges.
            $join = " LEFT JOIN {badge_issued} bi2 ON bi2.userid = u.id";
            $where = "AND (";
            $i = 0;
            foreach ($this->params as $param) {
                if ($i == 0) {
                    $where .= ' bi2.badgeid = :badgeid'.$i;
                } else {
                    $where .= ' OR bi2.badgeid = :badgeid'.$i;
                }
                $params['badgeid'.$i] = $param['badge'];
                $i++;
            }
            $where .= ") ";
            return array($join, $where, $params);
        } else {
            // User has received ALL of the required badges.
            $join = " LEFT JOIN {badge_issued} bi2 ON bi2.userid = u.id";
            $i = 0;
            foreach ($this->params as $param) {
                $i++;
                $where = ' AND bi2.badgeid = :badgeid'.$i;
                $params['badgeid'.$i] = $param['badge'];
            }
            return array($join, $where, $params);
        }
    }
95986
protected function whereChildSql() {
        $this->params = [];
        $sql = $this->parseWhere($this->wheres, $this->params);
        return $sql;
    }
381728
public function sqlFilters()
    {
        if (!$this->hasFilters()) {
            return '';
        }

        $criteria = $this->createFilter([
            'filters' => $this->filters()
        ]);

        $sql = $criteria->sql();
        if (strlen($sql) > 0) {
            $sql = ' WHERE '.$sql;
        }

        return $sql;
    }
977805
public function getQueryParams()
    {
        if (isset($this->_queryParams)) {
            return $this->_queryParams;
        }

        if ($queryString = $this->getQueryString()) {
            $result = [];
            parse_str($queryString, $result);
            return $this->_queryParams = $result;
        }

        return $this->_queryParams;
    }
707318
public function getSQLParamNames() : array
   {

      $out = [];

      foreach ( $this->_attributes as $attributeName => $attribute )
      {
         if ( Type::INIT_SQL === $attribute->getType() )
         {
            $out[] = $attributeName;
         }
      }

      return $out;

   }
822683
public function getQueryParams()
    {
        if (is_array($this->queryParams)) {
            return $this->queryParams;
        }

        if (empty($_SERVER['QUERY_STRING'])) {
            return [];
        }

        parse_str($_SERVER['QUERY_STRING'], $this->queryParams);

        return $this->queryParams;
    }
652
protected function findIdsByGivenCriteria()
    {
        $select = $this->getSelectAs($this->idField);

        $subQueryBuilder = $this->createSubQueryBuilder($select);
        if (null != $this->limit) {
            $subQueryBuilder->setMaxResults($this->limit)->setFirstResult($this->limit * ($this->page - 1));
        }

        foreach ($this->sortFields as $index => $sortField) {
            if ($sortField->getName() !== $this->idField->getName()) {
                $subQueryBuilder->addSelect($this->getSelectAs($sortField));
            }
        }

        $this->assignSortFields($subQueryBuilder);
        $this->assignParameters($this->queryBuilder);
        $ids = $subQueryBuilder->getQuery()->getArrayResult();

        // if no results are found - return
        if (count($ids) < 1) {
            return [];
        }

        $ids = array_map(
            function($array) {
                return $array[$this->idField->getName()];
            },
            $ids
        );

        return $ids;
    }
448302
protected function getIDListFromDB() : array
    {
        //Get product ID list
        $arProductIDList = (array) Product::active()->lists('id');
        if (empty($arProductIDList)) {
            return [];
        }

        //Check active offers
        if (Settings::getValue('check_offer_active')) {
            //Get product list with active offers
            $arProductIDListWithOffers = (array) Offer::active()->groupBy('product_id')->lists('product_id');
            if (empty($arProductIDListWithOffers)) {
                return [];
            }

            $arProductIDList = array_intersect($arProductIDList, $arProductIDListWithOffers);
        }

        return $arProductIDList;
    }
1258014
public function getResultIDs()
    {
        $results = $this->executeGetResults();
        $ids = [];
        foreach ($results as $result) {
            $ids[] = $result['uID'];
        }

        return $ids;
    }
1238160
protected function _getQuery()
    {
        $sSelTable = $this->_getViewName('oxselectlist');
        $sArtId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');

        return " from $sSelTable left join oxobject2selectlist on oxobject2selectlist.oxselnid = $sSelTable.oxid " .
                 "where oxobjectid = '$sArtId' ";
    }
479186
public function getJoins()
    {
        $template = "%s JOIN %s ON %s";
        $joinsStr = null;

        $joins = $this->_sql->getJoins();
        $tmpJoin = array();
        if (count($joins) > 0) {
            foreach ($joins as $join) {
                $tmpJoin[] = sprintf(
                    $template,
                    $join['type'],
                    $join['table'],
                    $join['onClause']
                );
            }
            $joinsStr = implode(PHP_EOL, $tmpJoin);
        }

        return $joinsStr;
    }
218906
protected function getUsers(): array
    {
        return $this->repository->sudo(function (Repository $repository) {
            $query = new LocationQuery();
            $query->filter = new ContentTypeIdentifier('user');
            $query->offset = 0;
            $query->limit = 10;
            $query->performCount = true;
            $query->sortClauses[] = new SortClause\ContentName();

            $users = [];
            do {
                $results = $repository->getSearchService()->findContent($query);
                foreach ($results->searchHits as $hit) {
                    $users[] = $repository->sudo(function (Repository $repository) use ($hit) {
                        return $repository->getUserService()->loadUser($hit->valueObject->id);
                    });
                }

                $query->offset += $query->limit;
            } while ($query->offset < $results->totalCount);

            return $users;
        });
    }
537230
protected function getSelectionCriteria()
    {
        $options = $this->request->getParameters();
        $payload = $this->getPayloadData();
        $options = array_merge($options, $payload);
        $this->request->setParameters($options);

        $criteria = [
            'params' => []
        ];

        if (null !== ($value = $this->request->getParameter(ApiOptions::FIELDS))) {
            $criteria['select'] = explode(',', $value);
        } else {
            $criteria['select'] = ['*'];
        }

        if (null !== ($value = $this->request->getPayloadData(ApiOptions::PARAMS))) {
            $criteria['params'] = $value;
        }

        if (null !== ($value = $this->request->getParameter(ApiOptions::FILTER))) {
            /** @type TableSchema $schema */
            /** @noinspection PhpUndefinedMethodInspection */
            $schema = $this->getModel()->getTableSchema();
            $native = $this->convertFilterToNative($value, $criteria['params'], [], $schema->getColumns());
            $criteria['condition'] = $native['where'];
            if (is_array($native['params'])) {
                if (is_array($criteria['params'])) {
                    $criteria['params'] = array_merge($criteria['params'], $native['params']);
                } else {
                    $criteria['params'] = $native['params'];
                }
            }
            //	Add current user ID into parameter array if in condition, but not specified.
            if (false !== stripos($value, ':user_id')) {
                if (!isset($criteria['params'][':user_id'])) {
                    $criteria['params'][':user_id'] = SessionUtility::getCurrentUserId();
                }
            }
        }

        $value = intval($this->request->getParameter(ApiOptions::LIMIT));
        $maxAllowed = $this->getMaxRecordsReturnedLimit();
        if (($value < 1) || ($value > $maxAllowed)) {
            // impose a limit to protect server
            $value = $maxAllowed;
        }
        $criteria['limit'] = $value;

        // merge in possible payload options
        $optionNames = [
            ApiOptions::OFFSET,
            ApiOptions::ORDER,
            ApiOptions::GROUP,
        ];

        foreach ($optionNames as $option) {
            if (null !== $value = $this->request->getParameter($option)) {
                $criteria[$option] = $value;
            } elseif (!empty($otherNames = ApiOptions::getAliases($option))) {
                foreach ($otherNames as $other) {
                    if (null !== $value = $this->request->getParameter($other)) {
                        $criteria[$option] = $value;
                    } elseif (null !== $value = $this->request->getPayloadData($other)) {
                        $criteria[$option] = $value;
                    }
                }
            }
            if (!isset($criteria[$option]) && ((null !== $value = $this->request->getPayloadData($option)))) {
                $criteria[$option] = $value;
            }
        }

        return $criteria;
    }
1015640
public function toSQL()
    {
        $sql = [];
        $this->params = [];

        $sql[] = 'WHERE';

        if (! $this->conditions) {
            $sql[] = '1';
        } else {
            foreach ($this->conditions as $index => $value) {
                if ( $index > 0 ) $sql[] = $value->chain_by;
                $sql[] = $value->toSQL();
            }
        }

        return join(' ', $sql);
    }
431809
public function get_completed_criteria_sql() {
        // We have only one criterion here, so taking the first one.
        $coursecriteria = reset($this->params);

        $join = " LEFT JOIN {course_completions} cc ON cc.userid = u.id AND cc.timecompleted > 0";
        $where = ' AND cc.course = :courseid ';
        $params['courseid'] = $this->courseid;

        // Add by date parameter.
        if (isset($param['bydate'])) {
            $where .= ' AND cc.timecompleted <= :completebydate';
            $params['completebydate'] = $coursecriteria['bydate'];
        }

        return array($join, $where, $params);
    }
312559
public function getSqlAppointmentsWhere()
    {
        if ($this->_data['gaf_filter_text1'] && $this->_data['gaf_filter_text2']) {
            $wheres[] = $this->getSqlWhereSingle($this->_data['gaf_filter_text1'], $this->_data['gaf_filter_text2'], $this->_fieldList2);
        }
        if ($this->_data['gaf_filter_text3'] && $this->_data['gaf_filter_text4']) {
            $wheres[] = $this->getSqlWhereSingle($this->_data['gaf_filter_text3'], $this->_data['gaf_filter_text4'], $this->_fieldList4);
        }
        foreach ($wheres as $key => $where) {
            if ($where == parent::NO_MATCH_SQL) {
                return parent::NO_MATCH_SQL;
            } elseif ($where == parent::MATCH_ALL_SQL) {
                unset($wheres[$key]);
            }
        }

        if ($wheres) {
            return '(' . join(' AND ', $wheres) . ')';
        } else {
            return parent::MATCH_ALL_SQL;
        }
    }
625898
public function getQueryParameters() {
        $params = array();
        $params['userId'] = $this->user_id;
        $params['itemId'] = $this->item_id;
        if (isset($this->optional['sessionId']))
            $params['sessionId'] = $this->optional['sessionId'];
        return $params;
    }