VuFind API Documentation

Search extends Gateway
in package
implements DbServiceAwareInterface Uses DbServiceAwareTrait, ExpirationTrait

Table Definition for search

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

author

Ere Maijala ere.maijala@helsinki.fi

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Main Site

Interfaces, Classes, Traits and Enums

DbServiceAwareInterface
Marker interface for classes that depend on the \VuFind\Db\Service\PluginManager

Table of Contents

$dbServiceManager  : PluginManager
Database service plugin manager
$tableManager  : PluginManager
Table manager
__construct()  : mixed
Constructor
beginTransaction()  : void
Begin a database transaction.
commitTransaction()  : void
Commit a database transaction.
createRow()  : object
Create a new row.
deleteExpired()  : int
Delete expired records. Allows setting of 'from' and 'to' ID's so that rows can be deleted in small batches.
destroySession()  : void
Destroy unsaved searches belonging to the specified session/user.
getDbService()  : T
Get a database service object.
getDbServiceManager()  : PluginManager
Get the service plugin manager. Throw an exception if it is missing.
getDbTable()  : Gateway
Get access to another table.
getOwnedRowById()  : Search|null
Get a single row, enforcing user ownership. Returns row if found, null otherwise.
getRowById()  : Search|null
Get a single row matching a primary key value.
getScheduledSearches()  : array<string|int, mixed>
Get scheduled searches.
getSearches()  : array<string|int, mixed>
Get an array of rows for the specified user.
getSearchRowsMatchingNormalizedSearch()  : array<string|int, Search>
Return existing search table rows matching the provided normalized search.
initializeFeatures()  : void
Initialize features
onPreInit()  : void
Customize the database object to include extra metadata about the search_object field so that it will be written correctly. This is triggered only when we're interacting with PostgreSQL; MySQL works fine without the extra hint.
rollBackTransaction()  : void
Roll back a database transaction.
saveSearch()  : Search
Add a search into the search table (history)
setDbServiceManager()  : void
Set the service plugin manager.
expirationCallback()  : void
Update the select statement to find records to delete.
getExpiredBatchLastId()  : int|null
Get the highest id to delete in a batch.

Properties

Methods

__construct()

Constructor

public __construct(Adapter $adapter, PluginManager $tm, array<string|int, mixed> $cfg[, RowGateway $rowObj = null ][, string $table = 'search' ]) : mixed
Parameters
$adapter : Adapter

Database adapter

$tm : PluginManager

Table manager

$cfg : array<string|int, mixed>

Laminas configuration

$rowObj : RowGateway = null

Row prototype object (null for default)

$table : string = 'search'

Name of database table to interface with

Return values
mixed

beginTransaction()

Begin a database transaction.

public beginTransaction() : void
Tags
throws
Exception
Return values
void

commitTransaction()

Commit a database transaction.

public commitTransaction() : void
Tags
throws
Exception
Return values
void

createRow()

Create a new row.

public createRow() : object
Return values
object

deleteExpired()

Delete expired records. Allows setting of 'from' and 'to' ID's so that rows can be deleted in small batches.

public deleteExpired(string $dateLimit[, int|null $limit = null ]) : int
Parameters
$dateLimit : string

Date threshold of an "expired" record in format 'Y-m-d H:i:s'.

$limit : int|null = null

Maximum number of rows to delete or null for no limit.

Return values
int

Number of rows deleted

destroySession()

Destroy unsaved searches belonging to the specified session/user.

public destroySession(string $sid[, int $uid = null ]) : void
Parameters
$sid : string

Session ID of current user.

$uid : int = null

User ID of current user (optional).

Tags
deprecated

Use SessionServiceInterface::destroySession()

Return values
void

getDbService()

Get a database service object.

public getDbService(class-string<\VuFind\Db\Service\T> $name) : T
Parameters
$name : class-string<\VuFind\Db\Service\T>

Name of service to retrieve

Tags
template

T

Return values
T

getDbTable()

Get access to another table.

public getDbTable(string $table) : Gateway
Parameters
$table : string

Table name

Return values
Gateway

getOwnedRowById()

Get a single row, enforcing user ownership. Returns row if found, null otherwise.

public getOwnedRowById(int $id, string $sessId, int $userId) : Search|null
Parameters
$id : int

Primary key value

$sessId : string

Current user session ID

$userId : int

Current logged-in user ID (or null if none)

Tags
deprecated

Use SessionServiceInterface::getSearchByIdAndOwner()

Return values
Search|null

getRowById()

Get a single row matching a primary key value.

public getRowById(int $id[, bool $exceptionIfMissing = true ]) : Search|null
Parameters
$id : int

Primary key value

$exceptionIfMissing : bool = true

Should we throw an exception if the row is missing?

Tags
throws
Exception
deprecated
Return values
Search|null

getScheduledSearches()

Get scheduled searches.

public getScheduledSearches() : array<string|int, mixed>
Tags
deprecated

Use SessionServiceInterface::getScheduledSearches()

Return values
array<string|int, mixed>

Array of VuFind\Db\Row\Search objects.

getSearches()

Get an array of rows for the specified user.

public getSearches(string $sid[, int $uid = null ]) : array<string|int, mixed>
Parameters
$sid : string

Session ID of current user.

$uid : int = null

User ID of current user (optional).

Tags
deprecated

Use SessionServiceInterface::getSearches()

Return values
array<string|int, mixed>

Matching SearchEntry objects.

getSearchRowsMatchingNormalizedSearch()

Return existing search table rows matching the provided normalized search.

public getSearchRowsMatchingNormalizedSearch(NormalizedSearch $normalized, string $sessionId, int|null $userId[, int $limit = PHP_INT_MAX ]) : array<string|int, Search>
Parameters
$normalized : NormalizedSearch

Normalized search to match against

$sessionId : string

Current session ID

$userId : int|null

Current user ID

$limit : int = PHP_INT_MAX

Max rows to retrieve (default = no limit)

Tags
deprecated

Use SearchNormalizer::getSearchesMatchingNormalizedSearch()

Return values
array<string|int, Search>

initializeFeatures()

Initialize features

public initializeFeatures(array<string|int, mixed> $cfg) : void
Parameters
$cfg : array<string|int, mixed>

Laminas configuration

Return values
void

onPreInit()

Customize the database object to include extra metadata about the search_object field so that it will be written correctly. This is triggered only when we're interacting with PostgreSQL; MySQL works fine without the extra hint.

public onPreInit(object $event) : void
Parameters
$event : object

Event object

Return values
void

rollBackTransaction()

Roll back a database transaction.

public rollBackTransaction() : void
Tags
throws
Exception
Return values
void

saveSearch()

Add a search into the search table (history)

public saveSearch(SearchNormalizer $normalizer, Results $results, string $sessionId, int|null $userId) : Search
Parameters
$normalizer : SearchNormalizer

Search manager

$results : Results

Search to save

$sessionId : string

Current session ID

$userId : int|null

Current user ID

Tags
deprecated

Use SearchNormalizer::saveNormalizedSearch()

Return values
Search

expirationCallback()

Update the select statement to find records to delete.

protected expirationCallback(Select $select, string $dateLimit) : void
Parameters
$select : Select

Select clause

$dateLimit : string

Date threshold of an "expired" record in format 'Y-m-d H:i:s'.

Return values
void

getExpiredBatchLastId()

Get the highest id to delete in a batch.

protected getExpiredBatchLastId(string $dateLimit, int $limit) : int|null
Parameters
$dateLimit : string

Date threshold of an "expired" record in format 'Y-m-d H:i:s'.

$limit : int

Maximum number of rows to delete.

Return values
int|null

Highest id value to delete or null if a limiting id is not available

Search results