Get Bulk Data
@param  integer $limit
@param  integer $sentences
@param  integer $chars
@param  boolean $with_images
@param  integer $image_min_size
@return array
343023
public function getBulkData($limit = 1, $sentences = 5, $chars = 200, $with_images = false, $image_min_size = 102400)
    {
        $wiki_api = $this->base_api . 'action=query&generator=random&grnnamespace=0&grnlimit=' . $limit . '&prop=info|extracts&inprop=url&explaintext=&exsectionformat=plain';

        if ($sentences > 0) {
            $wiki_api .= '&exsentences=' . $sentences;
        } elseif ($chars) {
            $wiki_api .= '&exchars=' . $chars;
        }

        $json_wapi = json_decode(file_get_contents($wiki_api), true);
        $result = [];

        if (!$json_wapi) {
            return $result;
        }

        foreach ($json_wapi['query']['pages'] as $page_id => $item) {
            $result[$page_id] = [
                'page_id' => $page_id,
                'title'   => $item['title'],
                'length'  => $item['length'],
                'url'     => $item['fullurl'],
                'text'    => isset($item['extract']) ? $item['extract'] : '',
            ];
        }

        $this->article_ids = array_keys($result);
        if ($with_images) {
            foreach ($this->article_ids as $page_id) {
                $wiki_api = $this->base_api . 'action=query&generator=images&prop=imageinfo&iiprop=url|size&pageids=' . $page_id;
                $json_wapi = json_decode(file_get_contents($wiki_api), true);
                $images = array();
                if ($json_wapi) {
                    foreach ($json_wapi['query']['pages'] as $item) {
                        $imageinfo = $item['imageinfo'][0];
                        if ($image_min_size > 0 && $imageinfo['size'] < $image_min_size) {
                            continue;
                        }
                        $images[] = $imageinfo['url'];
                    }
                }
                $result[$page_id]['images'] = $images;
            }
        }

        return array_values($result);
    }
495431
public function getSearchRequest($filter, $limit = 1, $conditions = [])
    {
        $db = $this->_getConnection();
        $table = $this->table;
        $self = $this;

        $request = new StorageDataRequest(
            [$filter, $limit],
            function ($filter, $limit) use ($db, $table, $self) {
                if (!$db) {
                    $self->logError('Missing connection on getSearchRequest on table: ' . $table);
                    return false;
                }
                
                //
                $filterBinds = [];
                foreach ($filter as $id => $filterItem) {
                    $filterBinds[$id] = $filterItem[2];  
                }
                //
                $filterBinds = $this->prepareBind($filterBinds, $db, false);
                //
                foreach ($filter as $id => &$filterItem) {
                    $filterItem[2] = $filterBinds[$id];
                } unset($filterItem);
                
                //
                $filtersWhereArray = $this->_prepapreFilters($filter);
                
                $query = 'SELECT * FROM ' . $table
                    . (!empty($filtersWhereArray) ? ' WHERE (' . implode(' ) AND (', $filtersWhereArray) . ')' : '')
                    . ' LIMIT '.$limit;

                $stmnt = $db->query($query);

                if (!$stmnt) {
                    $this->logError('Cannot execute getSearchRequest on table: ' . $table . ':' . implode(',', $db->errorInfo()), [
                        'code' => $db->errorCode(),
                    ]);

                    return false;
                }

                $result = $stmnt->fetchAll(PDO::FETCH_ASSOC);

                if (!$result && (int) $stmnt->errorCode() > 0) {
                    $this->logError('Error on execution on getSearchRequest on table: ' . $table . ':' . implode(',',
                            $stmnt->errorInfo()), [
                        'code' => $stmnt->errorCode(),
                    ]);

                    return false;
                }

                return $result;
            });

        return $request;
    }
87770
public function take($limit = null)
    {
        if ($limit !== null) {
            $this->limit($limit);
        }
        $this->executeSql();
        $cn = $this->model_name;
        return $cn::createModelsFromQuery($this);
    }
973699
public function words($limit = null) {
		// if a limit has been specified
		if ($limit !== null) {
			// get one entry more than requested
			$limit += 1;
		}

		// split the string into words
		$words = $this->splitByRegex('/[^\\w\']+/u', $limit, PREG_SPLIT_NO_EMPTY);

		// if a limit has been specified
		if ($limit !== null) {
			// discard the last entry (which contains the remainder of the string)
			array_pop($words);
		}

		// return the words
		return $words;
	}
329252
public function getLimitedContent( $limit = CoreGlobal::DISPLAY_TEXT_MEDIUM ) {

		$content = $this->content;

		if( strlen( $content ) > $limit ) {

			$content = substr( $content, 0, $limit );
		}

		return HtmlPurifier::process( $content );
	}
28642
public function getExcerpt($limit = 50, $more = '&hellip;')
    {
        $content = strip_tags($this->getContent());
        if (strlen($content) <= $limit) {
            return $content;
        }

        $content = mb_substr($content, 0, $limit);
        $content = mb_substr($content, 0, mb_strrpos($content, ' '));

        if (! empty($more)) {
            $content .= $more;
        }

        return $content;
    }
976499
public function getByPage($page = 1, $limit = 10, $with = array())
    {
        $result = new StdClass;
        $result->page = $page;
        $result->limit = $limit;
        $result->totalItems = 0;
        $result->items = array();

        $query = $this->make($with);
        $users = $query->skip($limit * ($page - 1))
            ->take($limit)
            ->get();
        $result->totalItems = $this->model->count();
        $result->items = $users->all();

        return $result;
    }
1326312
public static function get_by_transaction(Transaction $transaction, $limit = null) {
		$db = Database::Get();
		if (is_null($limit)) {
			$ids = $db->get_column('SELECT id FROM transaction_log WHERE transaction_id=?', [ $transaction->id ]);
		} else {
			$ids = $db->get_column('SELECT id FROM transaction_log WHERE transaction_id=? ORDER BY created DESC LIMIT ' . $limit, [ $transaction->id ]);
			$ids = array_reverse($ids);
		}

		$transaction_logs = [];
		foreach ($ids as $id) {
			$transaction_logs[] = self::get_by_id($id);
		}

		return $transaction_logs;
	}
298200
public function getPosts( $limit = 100 ) {

        return $this->parseGetPosts(
            $this->service->api( $this->getWallGetRequestUrl( $limit ), 'GET' ),
            'response',
            [
                'id',
                'text'
            ],
            [
                'service_id_author' => 'from_id',
                'service_id_post'   => 'id',
                'time_created'      => 'date',
                'content'           => 'text'
            ] );
    }
1312054
protected function fetch($fields=[], $limit=NULL, $order=NULL, $offset=NULL, &$count=FALSE)
    {
        if ($limit == self::FETCH_COUNT) {
            return $this->getCount($fields);
        }
        $data = $this->getDataList($fields, $limit, $order, $offset, $count !== FALSE);
        if ($count !== FALSE) {
            $count = $this->fetchCount();
        }
        return $this->resultAsModelList($data);
    }
1051985
public function getSearchRequest($filter, $limit = 1, $conditions = [])
    {
        $self = $this;
        $knownFilters = $this->_getSearchFilters();
        $request = new StorageDataRequest(
            [$filter, $limit, $conditions],
            function ($filter, $limit, $conditions) use ($self, $knownFilters) {
                $items = $self->getAllItems();
                $results = [];
                $filterRules = [];
                
                foreach ($filter as $filterRequest) {
                    if (\count($filterRequest) === 3) {
                        list ($key, $compare, $compareValue) = $filterRequest;
                        
                        if (isset($knownFilters[$compare])) {
                            $filterRules[] = [$key, $knownFilters[$compare], $compareValue];
                        } else {
                            trigger_error('Comparator not found for filter: '.json_encode($filterRequest).'');
                        }
                    } else {
                        trigger_error('Strange filter: less than 3 parameters, '.json_encode($filterRequest));
                    }
                }
                
                foreach ($items as $id) {
                    $pointer = $self->getPointer($id);
                    $isOk = true;
                    if ($pointer) {
                        $record = json_decode(stream_get_contents($pointer), true);
                        
                        if (isset($record[self::F_DATA])) {
                            foreach ($filterRules as $filterRule) {
                                list ($key, $function, $filterRequest) = $filterRule;
        
                                $isOk = $isOk && call_user_func($function, $record[self::F_DATA][$key] ?? null, $filterRequest);
        
                                if (!$isOk) {
                                    break;
                                }
                            }
    
                            if ($isOk) {
                                $results[$id] = [$this->primaryKey => $id] + $record[self::F_DATA];
                            }    
                        }
                        
                        $self->closePointer($pointer);
                        
                        if (count($results) >= $limit) {
                            break;
                        }
                    }
                }
                
                if ($results && $conditions) {
                    $self->applyConditions($results, $conditions);
                }
            
                return $results;
            }
        );
    
        return $request;
    }
1057472
function get_tops($limit = 10, $xattr = '') {
        $ret = array();
        if (!$this->_txt) return false;
        $xmode = false;
        $attrs = array();
        if ($xattr != '') {
            if (substr($xattr, 0, 1) == '~') {
                $xattr = substr($xattr, 1);
                $xmode = true;
            }
            foreach (explode(',', $xattr) as $tmp) {
                $tmp = strtolower(trim($tmp));
                if (!empty($tmp)) $attrs[$tmp] = true;
            }
        }

        // save the old offset
        $off = $this->_off;
        $this->_off = $cnt = 0;
        $list = array();
        while ($tmpa = $this->get_result()) {
            foreach ($tmpa as $tmp) {
                $tmp['attr'] = trim($tmp['attr']);
                if ($tmp['idf'] < 0.2 || substr($tmp['attr'], 0, 1) == '#') continue;
                // check attr filter
                if (count($attrs) > 0) {
                    if ($xmode == true && isset($attrs[$tmp['attr']])) continue;
                    if ($xmode == false && !isset($attrs[$tmp['attr']])) continue;
                }
                // check stopwords
                $word = strtolower($tmp['word']);
                if ($this->_rule_checkbit($word, PSCWS4_RULE_NOSTATS)) continue;
                // put to list
                if (isset($list[$word])) {
                    $list[$word]['weight'] += $tmp['idf'];
                    $list[$word]['times']++;
                } else {
                    $list[$word] = array('word' => $tmp['word'], 'times' => 1, 'weight' => $tmp['idf'], 'attr' => $tmp['attr']);
                }
            }
        }
        // restore the offset
        $this->_off = $off;
        // sort it & return
        if ( (float)substr(PHP_VERSION, 0, 3) >= 5.3 ) {
            $cmp_func = function($a, $b) {return ($b['weight'] > $a['weight'] ? 1 : -1);};
        } else {
            $cmp_func = create_function('$a,$b', 'return ($b[\'weight\'] > $a[\'weight\'] ? 1 : -1);');
        }

        usort($list, $cmp_func);
        if (count($list) > $limit) $list = array_slice($list, 0, $limit);
        return $list;
    }
263821
public function getFeed($limit = 12)
    {
        if (empty($this->userName)) {
            throw new InstagramException('Username cannot be empty');
        }

        if ($this->endCursor) {
            if (!$this->cacheManager instanceof CacheManager) {
                throw new CacheException('CacheManager object must be specified to use pagination');
            }

            $feed     = new JsonTransportFeed($this->client, $this->endCursor, $this->cacheManager);
            $hydrator = new JsonHydrator();
        } else {
            $feed     = new HtmlTransportFeed($this->client, $this->cacheManager);
            $hydrator = new HtmlHydrator();
        }

        $dataFetched = $feed->fetchData($this->userName, $limit);

        $hydrator->setData($dataFetched);

        return $hydrator->getHydratedData();
    }
663912
private function fetchRangeIds($limit, $start)
    {
        $qb = $this->createFilterAndSortQueryBuilder();
        $qb->select(['t.id', 'e.latest_version']);

        if (null !== $limit) {
            $qb->setFirstResult($start);
            $qb->setMaxResults($limit);
        }

        $rows = $this->connection->fetchAll($qb->getSQL());

        $ids = [];
        foreach ($rows as $row) {
            $ids[$row['id']] = $row['latest_version'];
        }

        return $ids;
    }
716973
public function readByUser(int $userId, int $expirationInSeconds, int $limit = null): array
    {
        $schema = $this->getDatabaseSchema();
        /** @var TokenInterface[] $tokens */
        $tokens = $this->readEnabledTokensByColumnWithExpirationCheck(
            $userId,
            $schema->getTokensUserIdentityColumn(),
            $expirationInSeconds,
            $schema->getTokensValueCreatedAtColumn(),
            ['*'],
            $limit
        );

        return $tokens;
    }
1022465
public static function limit($params) {
        $limit = $params['args'][0];
        $ormObject = !is_null($params['ormObject']) ? $params['ormObject'] : ORM::for_table($params['table']);
        
        return $ormObject->limit($limit);
    }
21574
public function LimitSentences($maxSentences = 2)
    {
        if (!is_numeric($maxSentences)) {
            throw new InvalidArgumentException("Text::LimitSentence() expects one numeric argument");
        }

        $value = $this->Plain();
        if (!$value) {
            return "";
        }

        // Do a word-search
        $words = preg_split('/\s+/u', $value);
        $sentences = 0;
        foreach ($words as $i => $word) {
            if (preg_match('/(!|\?|\.)$/', $word) && !preg_match('/(Dr|Mr|Mrs|Ms|Miss|Sr|Jr|No)\.$/i', $word)) {
                $sentences++;
                if ($sentences >= $maxSentences) {
                    return implode(' ', array_slice($words, 0, $i + 1));
                }
            }
        }

        // Failing to find the number of sentences requested, fallback to a logical default
        if ($maxSentences > 1) {
            return $value;
        } else {
            // If searching for a single sentence (and there are none) just do a text summary
            return $this->Summary(20);
        }
    }