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

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

        if ($this->method == BADGE_CRITERIA_AGGREGATION_ANY) {
            foreach ($this->params as $param) {
                $coursedata[] = " cc.course = :completedcourse{$param['course']} ";
                $params["completedcourse{$param['course']}"] = $param['course'];
            }
            if (!empty($coursedata)) {
                $extraon = implode(' OR ', $coursedata);
                $join = " JOIN {course_completions} cc ON cc.userid = u.id AND
                          cc.timecompleted > 0 AND ({$extraon})";
            }
            return array($join, $where, $params);
        } else {
            foreach ($this->params as $param) {
                $join .= " LEFT JOIN {course_completions} cc{$param['course']} ON
                          cc{$param['course']}.userid = u.id AND
                          cc{$param['course']}.course = :completedcourse{$param['course']} AND
                          cc{$param['course']}.timecompleted > 0 ";
                $where .= " AND cc{$param['course']}.course IS NOT NULL ";
                $params["completedcourse{$param['course']}"] = $param['course'];
            }
            return array($join, $where, $params);
        }
    }
944197
public function getAllUsers($sql = null, $params = null)
    {
        if ($sql == null) {
            $users = $this->findAll();
        }
        if ($sql != null) {
            $users = $this->findAllWhere($sql, $params);
        }

        return array_map(array($this, 'setupUser'), $users);
    }
829344
public function get_sql_where() {
        list($where, $params) = parent::get_sql_where();
        $where = preg_replace('/firstname/', 'u.firstname', $where);
        $where = preg_replace('/lastname/', 'u.lastname', $where);
        return [$where, $params];
    }
642268
public function getIncludeUserIds()
    {
        $ids = [];

        foreach ($this->usersToNotify as $user) {
            $ids[] = $user->getId();
        }

        return $ids;
    }
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;
    }
884622
public function get_all(string $id_option = null, bool $with_config = true): ?array
  {
    if ( $id_option = $this->_get_id_option($id_option) ){

      $fields = $this->fields;
      if ( !$with_config ){
        unset($fields['cfg']);
      }
      $table = $this->db->tsn($this->class_table, true);
      $cols = implode(', ', array_map(function($a) use($table){
        return $a === $this->fields['id'] ? "$table.$a" : "IFNULL(aliases.$a, $table.$a) AS $a";
      }, $fields));
      $id_opt = $this->db->cfn($this->fields['id_option'], $this->class_table, true);
      $id_user = $this->db->cfn($this->fields['id_user'], $this->class_table, true);
      $id_group = $this->db->cfn($this->fields['id_group'], $this->class_table, true);
      $num = $this->db->cfn($this->fields['num'], $this->class_table, true);
      $text = $this->db->cfn($this->fields['text'], $this->class_table, true);
      $id_alias = $this->db->cfn($this->fields['id_alias'], $this->class_table, true);
      $public = $this->db->cfn($this->fields['public'], $this->class_table, true);
      $sql = <<< MYSQL
SELECT $cols
FROM $table
  LEFT JOIN $table as aliases
    ON aliases.id = $id_alias
WHERE $id_opt = UNHEX(?)
AND ($id_user = UNHEX(?)
OR $id_group = UNHEX(?)
OR $public = 1)
ORDER BY IFNULL($num, $text)
MYSQL;
      if ( $rows =  $this->db->get_rows($sql, $id_option, $this->id_user, $this->id_group) ){
        return $with_config ? array_map(function($a){
          $cfg = $a['cfg'];
          unset($a['cfg']);
          if ( ($cfg = json_decode($cfg, true)) ){
            $a = bbn\x::merge_arrays($cfg, $a);
          }
          return $a;
        }, $rows) : $rows;
      }
      return [];
    }
    return null;
  }
796063
public function getParams()
    {
        $params = [];
        $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName());

        foreach ($this->getMap() as $criterion) {

            $table = null;
            foreach ($criterion->getAttachedCriterion() as $attachedCriterion) {
                $tableName = $attachedCriterion->getTable();

                $table = $this->getTableForAlias($tableName);
                if (null === $table) {
                    $table = $tableName;
                }

                if (
                    ($this->isIgnoreCase() || method_exists($attachedCriterion, 'setIgnoreCase'))
                    && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()
                ) {
                    $attachedCriterion->setIgnoreCase(true);
                }
            }

            $sb = '';
            $criterion->appendPsTo($sb, $params);
        }

        $having = $this->getHaving();
        if (null !== $having) {
            $sb = '';
            $having->appendPsTo($sb, $params);
        }

        return $params;
    }
784369
public function getSqlAppointmentsWhere()
    {
        if ($this->_activities && ($this->_activities !== true)) {
            $where = 'gap_id_activity IN (' . implode(', ', $this->_activities) . ')';

            if ($this->_procedures !== true) {
                $where .= ' AND ';
            }
        } else {
            $where = '';
        }
        if ($this->_procedures && ($this->_procedures !== true)) {
            $where .= 'gap_id_procedure IN (' . implode(', ', $this->_procedures) . ')';
        } elseif ($where && (! $this->_procedures)) {
            $where .= parent::NO_MATCH_SQL;
        }

        if ($where) {
            return "($where)";
        } else {
            return parent::NO_MATCH_SQL;
        }
    }
385474
public function getQueryParams() : array
    {
        $this->queryStrings->usePercentEncode(false);
        $r = $this->queryStrings->toArray(true);
        $this->queryStrings->usePercentEncode(true);

        return $r;
    }
98763
public function getQuery()
    {
        $query = $this->database->getSelectQuery()->from($this->table);

        foreach ($this->join as $join) {
            if (!is_array($join[2])) {
                $join[2] = [$join[2]];
            }

            $where = array_shift($join[2]);
            if (!empty($join[2])) {
                foreach ($join[2] as $i => $value) {
                    $join[2][$i] = $this->database->bind($value);
                }

                $where = vsprintf($where, $join[2]);
            }

            $query->join($join[0], $join[1], $where, $join[3]);
        }

        foreach ($this->filter as $i => $filter) {
            //array('post_id=%s AND post_title IN %s', 123, array('asd'));
            $where = array_shift($filter);
            if (!empty($filter)) {
                foreach ($filter as $i => $value) {
                    $filter[$i] = $this->database->bind($value);
                }

                $where = vsprintf($where, $filter);
            }

            $query->where($where);
        }

        return $query;
    }
109623
public function get()
    {
        $sql = "SELECT * FROM `$this->_table` ";

        $this->_param_list = array();

        if (!empty($this->_where_list)) {
            $sql .= "WHERE ";
            $first = true;
            foreach ($this->_where_list as $field_name => $field_settings) {
                $type          = isset($field_settings['type']) ? $field_settings['type'] : false;
                $field_value   = $field_settings['value'];
                $field_connect = isset($field_settings['op']) ? $field_settings['op'] : ' AND ';

                switch ($type) {
                    case 'like':
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name like '%:$field_name%'";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                    case 'in':
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name IN (:$field_name)";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                    default:
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name = :$field_name";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                }

                // we can assume that after the first iteration it's false
                $first = false;
            }
        }
        unset($field_connect, $field_name, $field_value, $type, $field_settings);

        if (!empty($this->_group)) {
            if (is_array($this->_group)) {
                $this->_limit = implode(',', $this->_group_by);
            }

            $sql .= ' GROUP BY ' . $this->_group_by;
        }

        if (!empty($this->_limit)) {
            if (is_array($this->_limit)) {
                $this->_limit = implode(',', $this->_limit);
            }

            $sql .= ' LIMIT ' . $this->_limit;
        }

        $this->last_sql = $sql;

        $this->__init_database();

        $stmt = $this->db->prepare($sql);
        // set the prepared statement
        for ($i = 0, $c = count($this->_param_list); $i < $c; $i++) {
            $stmt->bindParam($this->_param_list[$i][0], $this->_param_list[$i][1]);
        }


        if (!$stmt->execute()) return;

        $this->result = $stmt->fetchAll(MySQL::FETCH_OBJ);
    }
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);
        }
    }
472211
public function all()
    {
        $sql ="SELECT id, name, created_at FROM {$this->tableName} ORDER BY id DESC";
        $data = $this->adapter->selectAll($sql);

        $result = [];
        foreach ($data as $row) {
            $result[] = $this->_makeModel($row);
        }

        return $result;
    }
1368086
protected function getIDListFromDB() : array
    {
        $arElementIDList = (array) Product::getByCategory($this->sValue)->lists('id');

        //Get product ID list for additional category relation
        $arAdditionalElementIDList = (array) DB::table('lovata_shopaholic_additional_categories')->where('category_id', $this->sValue)->lists('product_id');
        $arElementIDList = array_merge($arElementIDList, $arAdditionalElementIDList);
        $arElementIDList = array_unique($arElementIDList);

        return $arElementIDList;
    }
1324037
private function getSearchQueryIdentities()
    {
        $identities = [];
        $queryIds   = [];
        $origData   = $this->optimizer->getOrigData();
        $data       = $this->optimizer->getData();

        // If optimizer was previously assigned to all queries, or is now set to all queries.
        $isAppliedToAllQueries = empty($data['quick_search_container'])
            || (bool) $data['quick_search_container']['apply_to'] === false;
        $wasAppliedToAllQueries = empty($origData['quick_search_container']['query_ids']);

        if (!empty($origData['quick_search_container']['query_ids'])) {
            $queryIds = array_merge($queryIds, $origData['quick_search_container']['query_ids']);
        }

        if (!empty($data['quick_search_container']['query_ids'])) {
            foreach ($data['quick_search_container']['query_ids'] as $query) {
                $queryIds[] = $query['id'];
            }
        }

        $queryIds = array_unique(array_filter($queryIds));

        if ($wasAppliedToAllQueries || $isAppliedToAllQueries) {
            $identities[] = \Smile\ElasticsuiteCatalog\Block\CatalogSearch\Result\Cache::POPULAR_SEARCH_CACHE_TAG;
        } elseif (!empty($queryIds)) {
            $popularQueryIds = $this->queryCollection
                ->setPopularQueryFilter($this->optimizer->getStoreId())
                ->setPageSize($this->getMaxCountCacheableSearchTerms($this->optimizer->getStoreId()))
                ->load()
                ->getColumnValues('query_id');

            if (!empty(array_intersect($queryIds, $popularQueryIds))) {
                $identities[] = \Smile\ElasticsuiteCatalog\Block\CatalogSearch\Result\Cache::POPULAR_SEARCH_CACHE_TAG;
            }
        }

        return $identities;
    }
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;
        }
    }
713256
public function getList()
    {
        $sql = $this->getSql();
        $select = $sql->select()
            ->columns(array($this->getIdentifierColumn()))
            ->from($this->getTableName())
            ->order(array('id' => 'asc'));

        $statement = $sql->prepareStatementForSqlObject($select);
        $results = $statement->execute();

        $identifiers = array();
        foreach($results as $result) {
            $identifiers[] = $result[$this->getIdentifierColumn()];
        }

        return $identifiers;
    }