Return SQL snippet for a period (beginning till end).

@param string $searchString to parse
@param string $fieldName (Model.field)
@param array $options (see Time::period)
@return string query SQL Query
491925
public static function periodAsSql($searchString, $fieldName, array $options = []) {
		$period = static::period($searchString, $options);
		return static::daysAsSql($period[0], $period[1], $fieldName);
	}
85574
protected function getRequireFiltersComponent(SearchQuery $searchQuery)
    {
        $fq = array();
        foreach ($searchQuery->require as $field => $values) {
            $requireq = array();

            foreach ($values as $value) {
                if ($value === SearchQuery::$missing) {
                    $requireq[] = "(*:* -{$field}:[* TO *])";
                } elseif ($value === SearchQuery::$present) {
                    $requireq[] = "{$field}:[* TO *]";
                } elseif ($value instanceof SearchQuery_Range) {
                    $start = $value->start;
                    if ($start === null) {
                        $start = '*';
                    }
                    $end = $value->end;
                    if ($end === null) {
                        $end = '*';
                    }
                    $requireq[] = "$field:[$start TO $end]";
                } else {
                    $requireq[] = $field . ':"' . $value . '"';
                }
            }

            $fq[] = '+(' . implode(' ', $requireq) . ')';
        }
        return $fq;
    }
1233889
public function datepicker($fieldName, $options = [])
    {
        $defaults = [
            'class' => 'form-control form-control-datepicker',
            'type' => 'text',
        ];
        $options = array_merge($defaults, $options);
        return parent::input($fieldName, $options);
    }
457020
public function setSearchString($searchString): void
    {
        $this->searchString = $searchString;
        $this->query = $this->createSearchQuery();
    }
182621
private String logAndGetQueryText(FieldSearchQuery query,
                                      String[] resultFields) //2004.05.02 wdn5e
            throws SQLException, QueryParseException {
        StringBuffer queryText = new StringBuffer("SELECT");
        if (query.getType() == FieldSearchQuery.TERMS_TYPE) {
            queryText.append(" doFields.pid FROM doFields"
                    + getWhereClause(query.getTerms()));
        } else {
            StringBuffer resultFieldsString = new StringBuffer();
            if (resultFields.length > 0) {
                String delimiter = " ";
                for (String element : resultFields) {
                    String dbColumn = "doFields." + dcFixup(element);
                    resultFieldsString.append(delimiter + dbColumn);
                    delimiter = ", ";
                }
            }
            queryText.append(resultFieldsString);
            queryText.append(" FROM doFields");
            queryText.append(getWhereClause(query.getConditions()));
            // disabled sorting: see bug 78
            //            queryText.append(" ORDER BY");
            //            queryText.append(resultFieldsString);

        }
        String qt = queryText.toString();
        logger.debug(qt);
        return qt;
    }
292966
public function runQuery($queryString){
		$this->affectedRows = false;

		$result = @pg_query($this->resource, $queryString);
		if($result === false)
			throw new DriverException(pg_last_error($this->resource), null, $queryString);

		$this->affectedRows = @pg_affected_rows($result);
		return $result;
	}
842225
public function runQuery($queryString){

		$this->affectedRows = false;
		if($this->dbCharset !== null)
			$queryString = iconv($this->charset, $this->dbCharset . '//IGNORE', $queryString);

		$result = $this->resource->query($queryString);

		if($result === false)
			throw new DriverException($this->resource->lastErrorMsg(), $this->resource->lastErrorCode(), $queryString);

		$this->affectedRows = $this->resource->changes();
		return $result;
	}
742619
public function filterByDateRange(
        string $filterName,
        string $field,
        array $options,
        array $values,
        int $applicationType = Filter::AT_LEAST_ONE,
        bool $aggregate = true,
        array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC
    ): self {
        return $this->filterByRange(
            $filterName,
            $field,
            $options,
            $values,
            $applicationType,
            Filter::TYPE_DATE_RANGE,
            $aggregate,
            $aggregationSort
        );
    }
36182
public function fetchField($field=null, $options=null)
    {
        $this->getQuery()->type('select');
        if ($options) {
            $this->getQuery()->set(static::formatQueryOptions($options));
        }
        if ($field) {
            $this->getQuery()->remove('fields')->set('fields', $field);
        }
        $fields = StringHelper::explode(',', $this->getQuery()['fields']);
        $fields = array_map(function ($v) {
            $vs = preg_split('/(as)?\s+/', trim($v));
            return $vs[count($vs)-1];
        }, $fields);
        
        $rows = $this->query();
        
        $result = [];
        if ($rows) foreach ($rows as $v) {
            $result[] = $v[$fields[0]];
        }
        return $result;
    }
731618
public function querystring($querystring = null, $withQuestionmark = true)
    {
        if (null !== $querystring) {
            $this->medium_querystring[] = ltrim($querystring, '?&');
            foreach ($this->alternatives as $alt) {
                $alt->querystring($querystring, $withQuestionmark);
            }
        }

        if (empty($this->medium_querystring)) {
            return '';
        }

        // join the strings
        $querystring = implode('&', $this->medium_querystring);
        // explode all strings
        $query_parts = explode('&', $querystring);
        // Join them again now ensure the elements are unique
        $querystring = implode('&', array_unique($query_parts));

        return $withQuestionmark ? ('?' . $querystring) : $querystring;
    }
462309
public function getResult($wheres = [], $selectField = '*', $options = NULL)
    {
        try {
            if (is_array($wheres) && count($wheres) > 0) {
                foreach ($wheres as $field => $value) {
                    if (is_array($value)) {
                        $this->db->where($field, $value, self::OPERATOR_IS_IN);
                    } else {
                        $this->db->where($field, $value, self::OPERATOR_EQUAL_TO);
                    }
                }
            } else {
                $this->db->where($this->primaryKey, $wheres, self::OPERATOR_EQUAL_TO);
            }
            if (isset($options['orderBy']) && is_array($options['orderBy'])) {
                foreach ($options['orderBy'] as $column => $direction) {
                    $this->db->orderBy($column, $direction);
                }
            }
            $result = $this->db->get($this->table, NULL, $selectField);
            $this->debug->debug(__FUNCTION__, 'Format is get all Result => ' . json_encode($result));

            return $result;
        }
        catch (\Exception $e) {
            $this->debug->error(__FUNCTION__, $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage());

            return NULL;
        }
    }
686424
public function countNumberOfUserInSearch($searchString = null)
    {
        $builder = $this->buildUserSearchQuery($searchString);

        return $builder->select($builder->expr()->count('u.id'))
            ->getQuery()
            ->getSingleScalarResult();
    }
754989
public function query($sql, $options = [])
    {
        $resultMode = isset($options[self::RESULT_MODE_INDEX]) ? (int) $options[self::RESULT_MODE_INDEX] : MYSQLI_STORE_RESULT;
        /**
         * the RETURN_MODE_INDEX should contain one of the following constants http://php.net/manual/en/mysqli-result.fetch-all.php
         */
        $returnMode = isset($options[self::RESULT_RETURN_MODE_INDEX]) ? (int) $options[self::RESULT_RETURN_MODE_INDEX] : MYSQLI_BOTH;
        try {
            /**
             * @var \mysqli_result $result
             */
            $result = $this->getResource()->query($sql, $resultMode);
            switch($options[self::RESULT_TYPE_INDEX])
            {
                case self::RESULT_TYPE_GENERATOR:
                    return $this->rowGenerator($result, $returnMode);
                    break;

                case self::RESULT_TYPE_NUM_ARRAY:
                case self::RESULT_TYPE_ASSOC_ARRAY;
                    return $result->fetch_all($returnMode);
                    break;

                case self::RESULT_TYPE_ITERATOR:
                    return new \ArrayIterator($result->fetch_all($returnMode));
                    break;

                case self::RESULT_TYPE_OBJECT_ARRAY:
                    $gen = $this->rowGenerator($result, $returnMode);
                    $result = [];
                    foreach ($gen as $row) {
                        $result[] = $row;
                    }
                    return $result;

                default:
                    return $this->getResult()->fetch_all();
                    break;
            }
        } catch (\mysqli_sql_exception $e) {
            return false;
        }
    }
741952
public function input($fieldName, $options = array()) {
		$this->_inputType = null;
		$this->_fieldName = $fieldName;
		$options = $this->_initInputOptions($options);

		return parent::input($fieldName, $options);
	}
564356
public function search(string $search, $properties = null, array $options = null)
    {
        return $this->__call('search', [$search, $properties, $options]);
    }
1039488
private function _getReducedDQLQueryPart($queryPartName, $options = array())
    {
        $queryPart = $this->getDQLPart($queryPartName);

        if (empty($queryPart)) {
            return (isset($options['empty']) ? $options['empty'] : '');
        }

        return (isset($options['pre']) ? $options['pre'] : '')
             . (is_array($queryPart) ? implode($options['separator'], $queryPart) : $queryPart)
             . (isset($options['post']) ? $options['post'] : '');
    }
252387
public function getNativeQuery(array $options = array(), $asQueryString = true)
    {
        $queryComponents = $this->mapQueryKey($this->queryComponents);

        if($asQueryString) {
            $query = http_build_query($queryComponents, null, null, $this->encType);

            if(isset($options['urlencode']) && !$options['urlencode']) {
                return urldecode($query);
            }
            return $query;
        }

        return $queryComponents;
    }