public function add(string $lastSearchesKeywords, int $lastSearchesLimit)
    {
        $nextSequenceId = $this->resolveNextSequenceIdForGivenLimit($lastSearchesLimit);
        $rowsCount = $this->count();
        if ($nextSequenceId < $rowsCount) {
            $this->update([
                'sequence_id' => $nextSequenceId,
                'keywords' => $lastSearchesKeywords
            ]);
            return;
        }

        $queryBuilder = $this->getQueryBuilder();
        $queryBuilder
            ->insert($this->table)
            ->values([
                'sequence_id' => $nextSequenceId,
                'keywords' => $lastSearchesKeywords,
                'tstamp' => time()
            ])
            ->execute();
    }
public function add(string $lastSearchesKeywords, int $lastSearchesLimit)
    {
        $nextSequenceId = $this->resolveNextSequenceIdForGivenLimit($lastSearchesLimit);
        $rowsCount = $this->count();
        if ($nextSequenceId < $rowsCount) {
            $this->update([
                'sequence_id' => $nextSequenceId,
                'keywords' => $lastSearchesKeywords
            ]);
            return;
        }

        $queryBuilder = $this->getQueryBuilder();
        $queryBuilder
            ->insert($this->table)
            ->values([
                'sequence_id' => $nextSequenceId,
                'keywords' => $lastSearchesKeywords,
                'tstamp' => time()
            ])
            ->execute();
    }
public function add ( string $ lastSearchesKeywords , int $ lastSearchesLimit ) { $ nextSequenceId = $ this -> resolveNextSequenceIdForGivenLimit ( $ lastSearchesLimit ) ; $ rowsCount = $ this -> count ( ) ; if ( $ nextSequenceId < $ rowsCount ) { $ this -> update ( [ 'sequence_id' => $ nextSequenceId , 'keywords' => $ lastSearchesKeywords ] ) ; return ; } $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ queryBuilder -> insert ( $ this -> table ) -> values ( [ 'sequence_id' => $ nextSequenceId , 'keywords' => $ lastSearchesKeywords , 'tstamp' => time ( ) ] ) -> execute ( ) ; }
Adds keywords to last searches or updates the oldest row by given limit.

@param string $lastSearchesKeywords
@param int $lastSearchesLimit
@return void
Adds keywords to last searches or updates the oldest row by given limit .