It returns the most recent announcements that can be displayed on Admin.

@param integer $limit
@param array $config
@return \cmsgears\notify\common\models\resources\Announcement
494696
public function getRecentByAdmin( $limit = 5, $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		$siteId = Yii::$app->core->siteId;

		$config[ 'conditions' ][] = "$modelTable.access >=" . Announcement::ACCESS_APP_ADMIN;

		return $modelClass::find()
			->where( $config[ 'conditions' ] )
			->andWhere( [ 'siteId' => $siteId, 'status' => $modelClass::STATUS_ACTIVE ] )
			->limit( $limit )
			->orderBy( 'createdAt DESC' )
			->all();
	}
1321245
public function findLastUpdated($limit = 5)
    {
        $query = $this->createQueryBuilder('c')
            ->orderBy('c.updatedAt', 'DESC')
            ->where('c.layout = :layout')
            ->setParameter(':layout', false)
            ->setMaxResults($limit)
            ->getQuery();

        return $query->getResult();
    }
803190
public function getByStatus( $status, $config = [] ) {

		$limit = $config[ 'limit' ] ?? 10;

		$modelClass	 = static::$modelClass;
		$modelTable	 = $modelClass::tableName();

		$query = $modelClass::find()->where( [ "$modelTable.status" => $status ] );

		$query->limit( $limit );

		return $query->orderBy( [ 'id' => SORT_DESC ] )->all();
	}
986016
public static function data_for_messagearea_search_messages($userid, $search, $limitfrom = 0, $limitnum = 0) {
        global $CFG, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        $systemcontext = context_system::instance();

        $params = array(
            'userid' => $userid,
            'search' => $search,
            'limitfrom' => $limitfrom,
            'limitnum' => $limitnum

        );
        $params = self::validate_parameters(self::data_for_messagearea_search_messages_parameters(), $params);
        self::validate_context($systemcontext);

        if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
            throw new moodle_exception('You do not have permission to perform this action.');
        }

        $messages = \core_message\api::search_messages(
            $params['userid'],
            $params['search'],
            $params['limitfrom'],
            $params['limitnum']
        );

        $data = new \stdClass();
        $data->contacts = [];
        foreach ($messages as $message) {
            $contact = new \stdClass();
            $contact->userid = $message->userid;
            $contact->fullname = $message->fullname;
            $contact->profileimageurl = $message->profileimageurl;
            $contact->profileimageurlsmall = $message->profileimageurlsmall;
            $contact->messageid = $message->messageid;
            $contact->ismessaging = $message->ismessaging;
            $contact->sentfromcurrentuser = false;
            if ($message->lastmessage) {
                if ($message->userid !== $message->useridfrom) {
                    $contact->sentfromcurrentuser = true;
                }
                $contact->lastmessage = shorten_text($message->lastmessage, 60);
            } else {
                $contact->lastmessage = null;
            }
            $contact->lastmessagedate = $message->lastmessagedate;
            $contact->showonlinestatus = is_null($message->isonline) ? false : true;
            $contact->isonline = $message->isonline;
            $contact->isblocked = $message->isblocked;
            $contact->isread = $message->isread;
            $contact->unreadcount = $message->unreadcount;
            $contact->conversationid = $message->conversationid;

            $data->contacts[] = $contact;
        }

        return $data;
    }
6089
public function generateLimit($limitCount, $limitOffset, &$limit)
    {
        $limit = "";

        if (empty($limitCount)) {
            return;
        }

        $limit = "$limitCount";

        if (! empty($limitOffset)) {
            $limit .= ",$limitOffset";
        }
    }
14547
public function getLimitedSummary( $limit = CoreGlobal::DISPLAY_TEXT_MEDIUM ) {

		$summary = $this->summary;

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

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

		return HtmlPurifier::process( $summary );
	}
462733
protected function getLimitQuery( $limits = array() )
	{
		if( is_array( $limits ) && count( $limits ) == 2 )
			$limits	= ' LIMIT '.$limits[0].', '.$limits[1];
		else if( is_int( $limits ) && $limits )
			$limits	= ' LIMIT 0, '.$limits;
		else
			$limits	= '';
		return $limits;
	}
831156
public function getSiteStats( $config = [] ) {

		$status	= isset( $config[ 'status' ] ) ? $config[ 'status' ] : null;
		$type	= isset( $config[ 'type' ] ) ? $config[ 'type' ] : null;
		$limit	= isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 0;

		$modelClass	= static::$modelClass;
        $modelTable	= $modelClass::tableName();

        $query = new Query();

        $query->select( [ 'siteId', 'count(id) as total' ] )
			->from( $modelTable );

		// Filter Status
		if( isset( $status ) ) {

			$query->where( "$modelTable.status=:status", [ ':status' => $status ] );
		}

		// Filter Type
		if( isset( $type ) ) {

			$query->andWhere( "$modelTable.type=:type", [ ':type' => $type ] );
		}

		// Limit
		if( $limit > 0 ) {

			$query->limit( $limit );
		}

		// Group and Order
		$query->groupBy( 'siteId' )->orderBy( 'total DESC' );

        return $query->all();
    }
1105277
public function read($limit = 0)
    {
        $this->limit($limit);
        $query = $this->buildSelect();
        $this->run($query['query'], $query['param']);

        return $this->next();
    }
1125425
public static function getAdapterForPosts($limit=5,$tag='')
	{
		return static::find()->where('status="'.self::STATUS_PUBLISHED.'" AND tags LIKE "%'.$tag.'%"')
					->orderBy('created_at DESC')
					->limit($limit);
	}
287544
public function all($limit = 5)
    {
        $all = Auth::user()->notifications->take($limit);

        return $all->map(function ($item) {
            return $this->toCollect($item);
        });
    }
1189682
public function actionNewPlain($limit = 10)
    {
        if ($limit === 'all') {
            $limit = null;
        } else {
            $limit = (int) $limit;
            if ($limit < 1) {
                throw new Exception("The limit must be greater than 0.");
            }
        }

        $migrations = $this->getNewMigrations();

        if (empty($migrations)) {
            echo 'None';
        } else {
            $n = count($migrations);
            echo "Found $n new " . ($n === 1 ? 'migration' : 'migrations') . ":\n";

            foreach ($migrations as $migration) {
                echo $migration . "\n";
            }
        }
    }
962674
protected function getListLogOrder(array $limit)
    {
        $conditions = array(
            'limit' => $limit,
            'order_id' => $this->data_order['order_id']
        );

        return (array) $this->order_history->getList($conditions);
    }
773071
public function findRelevantEvents($offset, $limit)
    {
        $query = $this->prepareRelevantEventsQuery();

        $query->getQueryBuilder()->setFirstResult($offset);
        $query->getQueryBuilder()->setMaxResults($limit);

        return $query->execute();
    }
1359748
public function actionSuggest($limit=10) 
	{
		if(Yii::app()->request->isAjaxRequest) {
			$term = Yii::app()->getRequest()->getParam('term');
			if($term) {
				$criteria = new CDbCriteria;
				$criteria->select = 'tag_id, body';
				$criteria->addInCondition('t.publish', array(0,1));
				$criteria->compare('body',$this->urlTitle($term), true);
				$criteria->limit = $limit;
				$criteria->order = "tag_id ASC";
				$model = OmmuTags::model()->findAll($criteria);

				if($model) {
					foreach($model as $items) {
						$result[] = array('id' => $items->tag_id, 'value' => $items->body);
					}
				} else
					$result[] = array('id' => 0, 'value' => $term);
			}
			echo CJSON::encode($result);
			Yii::app()->end();
			
		} else
			throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.'));
	}
1342208
public function get_logs($limitfrom = 0, $limitnum = 0) {
        global $DB;

        \core_analytics\manager::check_can_manage_models();

        return $DB->get_records('analytics_models_log', array('modelid' => $this->get_id()), 'timecreated DESC', '*',
            $limitfrom, $limitnum);
    }
412189
public function formatLimit($limit) {
        if ($limit) {
            return sprintf($this->getClause(self::LIMIT), (int) $limit);
        }

        return '';
    }