@param string $query
@param int $limit
@param bool $showData

@param null $include
@param null $exclude
@return array
976016
public function search($query, $limit = 10000, $showData = true, $include = null, $exclude = null)
    {
        $showData = $showData === true ? 1 : 0;

        $uri = "{$this->uri}?q=" . urlencode($query) . "&limit=$limit" . "&showData=$showData";

        if ($include) {
            $uri .= "&include=$include";
        } elseif($exclude) {
            $uri .= "&exclude=$exclude";
        }

        $response = Request::get($uri)
            ->authenticateWith($this->username, $this->password
            )->send();

        return $this->processResponse($response);
    }
1168909
public function search(string $query, $limit = 30, $start = 0, $sort = null)
    {
        if ($query == '*.*' && $limit == 30 && $start == 0 && $sort == 'lastupdated desc') {
            $result = $this->fetchFromCache();

            if (null === $result) {
                $result = $this->search->search($query, $limit, $start, $sort);
                $this->saveToCache($result);
            }

            return $result;
        } else {
            return $this->search->search($query, $limit, $start, $sort);
        }
    }
96716
public function scopeUntil($query, $until = null)
    {
        if (!$until) {
            return $query;
        }

        return $query->where('date', '<', $until->toDateTimeString());
    }
775280
public function scopeAutocompleteTitle(Builder $query, $title, $limit)
    {
        return $query
            ->currentVersion()
            ->select('title', 'primary_uri')
            ->where('title', 'like', '%'.$title.'%')
            ->limit($limit)
            ->orderBy(DB::raw('length(title)'), 'asc');
    }
899541
protected function set_limit($query, $limit = 0, $offset = 0)
    {
        $limit  = intval($limit);
        $offset = intval($offset);
        $end    = $offset + $limit;

        // query without OFFSET
        if (!$offset) {
            $query = preg_replace('/^SELECT\s/i', "SELECT TOP $limit ", $query);
            return $query;
        }

        $orderby = stristr($query, 'ORDER BY');
        $offset += 1;

        if ($orderby !== false) {
            $query = trim(substr($query, 0, -1 * strlen($orderby)));
        }
        else {
            // it shouldn't happen, paging without sorting has not much sense
            // @FIXME: I don't know how to build paging query without ORDER BY
            $orderby = "ORDER BY 1";
        }

        $query = preg_replace('/^SELECT\s/i', '', $query);
        $query = "WITH paging AS (SELECT ROW_NUMBER() OVER ($orderby) AS [RowNumber], $query)"
            . " SELECT * FROM paging WHERE [RowNumber] BETWEEN $offset AND $end ORDER BY [RowNumber]";

        return $query;
    }
413071
final public function queryArray(string $query)
    {
        $result = $this->queryResult($query);
        if (false === $result) {
            return false;
        }

        $return = [];
        while (false !== $row = $result->fetchRow()) {
            $return[] = $row;
        }
        return $return;
    }
1365915
public static function queryFilter(ActiveQuery &$query, array $get)
    {
        if(!empty($get['text'])){
            $query->andFilterWhere(['LIKE', 'title', $get['text']]);
        }else{
            if(!empty($get['category_id'])){
                $query->andFilterWhere(['parent_id' => $get['category_id']]);
            }else {
                $query->andFilterWhere(['parent_id' => 0]);
            }
        }
    }
858889
public function queryFromFilter(Query $query, array $data = [])
    {
        $query = parent::queryFromFilter($query, $data);

        //"Name" field
        if (!empty($data['name']) && strlen($data['name']) > 2) {
            $query->where([sprintf('%s.tag LIKE', $this->getAlias()) => sprintf('%%%s%%', $data['name'])]);
        }

        return $query;
    }
1276881
public function getCustomList(QueryBuilder $queryBuilder, $start = 0, $limit = 0)
    {
        $parameters = array(
            'select' => $queryBuilder->getSelect(),
            'where'  => $queryBuilder->getWhere(),
            'order'  => $queryBuilder->getOrder(),
            'start'  => $start,
            'limit'  => $limit,
        );

        $parameters = array_filter($parameters);

        $supported = $this->isSupported('getList');

        return (true === $supported) ? $this->makeRequest($this->endpoint, $parameters) : $supported;
    }
856728
public function searchChannels($query, $limit = 25, $offset = 0)
    {
        if (!is_string($query)) {
            throw new InvalidTypeException('Query', 'string', gettype($query));
        }

        if (empty($query)) {
            throw new TwitchApiException('A \'query\' parameter is required.');
        }

        if (!$this->isValidLimit($limit)) {
            throw new InvalidLimitException();
        }

        if (!$this->isValidOffset($offset)) {
            throw new InvalidOffsetException();
        }

        $params = [
            'query' => $query,
            'limit' => intval($limit),
            'offset' => intval($offset),
        ];

        return $this->get('search/channels', $params);
    }
927344
final public function modifyLimitQuery($query, $limit, $offset = null)
    {
        if ($limit !== null) {
            $limit = (int) $limit;
        }

        $offset = (int) $offset;

        if ($offset < 0) {
            throw new DBALException(sprintf(
                'Offset must be a positive integer or zero, %d given',
                $offset
            ));
        }

        if ($offset > 0 && ! $this->supportsLimitOffset()) {
            throw new DBALException(sprintf(
                'Platform %s does not support offset values in limit queries.',
                $this->getName()
            ));
        }

        return $this->doModifyLimitQuery($query, $limit, $offset);
    }
1007160
final public static function limitFindBySql (string $sqlQuery, int $limit=0)
	{
		$resultArray = static::findBySql($sqlQuery.static::limitQuery($limit));
		if (empty($resultArray)) return FALSE;
		return ($limit == 1) ? array_shift($resultArray) : $resultArray;
	}
893580
public function compile_limit_with_offset( &$query ) 
	{
		if ( is_null( $query->limit ) )
		{
			return "";
		}

		return ' limit '.( (int) $query->offset ).', '.( (int) $query->limit );
	}
619917
private function getSearchQueryLimit($query, $limit, $offset)
	{
		if ($limit > -1) {
			$query->limit($limit);
			$query->offset($offset);
		}

		return $query;
	}
486977
public final function findAll($query = null, array $queryParams = null, $limit = null): EntityCollection
    {
        $queryBuilder = new QueryBuilder($this->db->getLink());
        $queryBuilder->setTable($this->table);

        $queryBuilder->select("{$this->table}.*");

        if (method_exists($this, 'onFind')) {
            $queryBuilder = $this->onFind($queryBuilder);
            if (!$queryBuilder || !($queryBuilder instanceof QueryBuilder)) {
                throw new InvalidValueException('You should return query builder back from onFind()!');
            }
        }

        $isEmptyQuery = empty($query);
        $isEmptyQueryParams = empty($queryParams);

        // fetch all rows, oh ohh..
        // e.g: findAll()
        if ($isEmptyQuery) {
            // nothing to do..
        }
        // fetch all rows by primary key with given params
        // e.g: findAll([1,2,3])
        elseif (!$isEmptyQuery && $isEmptyQueryParams) {
            $queryBuilder->where("{$this->table}.{$this->tablePrimary} IN(?)", [$query]);
        }
        // fetch all rows with given params and params
        // e.g: findAll('id IN (?)', [[1,2,3]])
        // e.g: findAll('id IN (?,?,?)', [1,2,3])
        elseif (!$isEmptyQuery && !$isEmptyQueryParams) {
            // now, it is user's responsibility to append table(s) before field(s)
            $queryBuilder->where($query, $queryParams);
        }

        @ [$limitStart, $limitStop] = (array) $limit;
        if ($limitStart !== null) {
            $queryBuilder->limit((int) $limitStart, $limitStop);
        }

        $hasOnEntity = method_exists($this, 'onEntity');

        $entityCollection = new EntityCollection();
        foreach ($queryBuilder->run() as $result) {
            $entity = new Entity($this, (array) $result);
            if ($hasOnEntity) {
                $this->onEntity($entity);
            }
            $entityCollection->addEntity($entity);
        }

        return $entityCollection;
    }
461884
protected function _buildLimitPart($limit, $query)
    {
        if ($limit === null || $query->clause('offset') === null) {
            return '';
        }

        return sprintf(' FETCH FIRST %d ROWS ONLY', $limit);
    }
840326
public function read ($list_name, $limit = NULL, $query = NULL, $view = NULL, $sort = NULL, $options = NULL) {
		// Check limit is set
		if ($limit < 1 || is_null($limit)) {
			$limit = $this->MAX_ROWS;
		}

		// Create Query XML is query is being used
		$xml_options = '';
		$xml_query   = '';
		$fields_xml = '';

		// Setup Options
		if ($query instanceof Service\QueryObjectService) {
			$xml_query = $query->getCAML();
			$xml_options = $query->getOptionCAML();
		} else {

			if (!is_null($query)) {
				$xml_query .= $this->whereXML($query); // Build Query
			}
			if (!is_null($sort)) {
				$xml_query .= $this->sortXML($sort);// add sort
			}

			// Add view or fields
			if (!is_null($view)){
				// array, fields have been specified
				if(is_array($view)){
					$xml_options .= $this->viewFieldsXML($view);
				}else{
					$xml_options .= '<viewName>' . $view . '</viewName>';
				}
			}
		}

		// If query is required
		if (!empty($xml_query)) {
			$xml_options .= '<query><Query>' . $xml_query . '</Query></query>';
		}

		/*
		 * Setup basic XML for querying a SharePoint list.
		 * If rowLimit is not provided SharePoint will default to a limit of 100 items.
		 */
		$CAML = '
			<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
				<listName>' . $list_name . '</listName>
				<rowLimit>' . $limit . '</rowLimit>
				' . $xml_options . '
				<queryOptions xmlns:SOAPSDK9="http://schemas.microsoft.com/sharepoint/soap/" >
					<QueryOptions>
						' . $options . '
					</QueryOptions>
				</queryOptions>
			</GetListItems>';

		// Ready XML
		$xmlvar = new \SoapVar($CAML, XSD_ANYXML);
		$result = NULL;

		// Attempt to query SharePoint
		try {
			$result = $this->xmlHandler($this->soapClient->GetListItems($xmlvar)->GetListItemsResult->any);
		} catch (\SoapFault $fault) {
			$this->onError($fault);
		}

		// Return a XML as nice clean Array
		return $result;
	}