Open Journal Systems  3.3.0
PKP\Services\QueryBuilders\PKPContextQueryBuilder Class Reference
Inheritance diagram for PKP\Services\QueryBuilders\PKPContextQueryBuilder:
PKP\Services\QueryBuilders\Interfaces\EntityQueryBuilderInterface APP\Services\QueryBuilders\ContextQueryBuilder

Public Member Functions

 filterByIsEnabled ($isEnabled)
 
 filterByUserId ($userId)
 
 getCount ()
 
 getIds ()
 
 getManySummary ()
 
 getQuery ()
 
 searchPhrase ($phrase)
 

Protected Attributes

 $db
 
 $dbIdColumn
 
 $dbSettings
 
 $isEnabled = null
 
 $searchPhrase = null
 
 $userId
 

Detailed Description

Definition at line 20 of file PKPContextQueryBuilder.inc.php.

Member Function Documentation

◆ filterByIsEnabled()

PKP\Services\QueryBuilders\PKPContextQueryBuilder::filterByIsEnabled (   $isEnabled)

Set isEnabled filter

Parameters
$isEnabledboolean
Returns
\PKP\Services\QueryBuilders\PKPContextQueryBuilder

Definition at line 65 of file PKPContextQueryBuilder.inc.php.

References PKP\Services\QueryBuilders\PKPContextQueryBuilder\$isEnabled.

◆ filterByUserId()

PKP\Services\QueryBuilders\PKPContextQueryBuilder::filterByUserId (   $userId)

Set userId filter

The user id can access contexts where they are assigned to a user group. If the context is disabled, they must be assigned to ROLE_ID_MANAGER user group.

Parameters
$userIdboolean
Returns
\PKP\Services\QueryBuilders\PKPContextQueryBuilder

Definition at line 81 of file PKPContextQueryBuilder.inc.php.

References PKP\Services\QueryBuilders\PKPContextQueryBuilder\$userId.

◆ getCount()

PKP\Services\QueryBuilders\PKPContextQueryBuilder::getCount ( )

Get a count of the number of rows that match the select conditions configured in this query builder.

Returns
int

Implements PKP\Services\QueryBuilders\Interfaces\EntityQueryBuilderInterface.

Definition at line 101 of file PKPContextQueryBuilder.inc.php.

◆ getIds()

PKP\Services\QueryBuilders\PKPContextQueryBuilder::getIds ( )

Get a list of ids that match the select conditions configured in this query builder.

Returns
array

Implements PKP\Services\QueryBuilders\Interfaces\EntityQueryBuilderInterface.

Definition at line 112 of file PKPContextQueryBuilder.inc.php.

◆ getManySummary()

PKP\Services\QueryBuilders\PKPContextQueryBuilder::getManySummary ( )

Get the name and basic data for a set of contexts

This returns data from the main table and the name of the context in its primary locale.

Returns
array

Definition at line 128 of file PKPContextQueryBuilder.inc.php.

◆ getQuery()

PKP\Services\QueryBuilders\PKPContextQueryBuilder::getQuery ( )

Get a query builder with the applied select, where and join clauses based on builder's configuration

This returns an instance of Laravel's query builder.

Call the get method on a query builder to return an array of matching rows.

$qb = new \PKP\Services\QueryBuilders\PublicationQueryBuilder();
$result = $qb
->filterByContextIds(1)
->getQuery()
->get();

Or use the query builder to retrieve objects from a DAO. This example retrieves the first 20 matching Publications.

$qo = $qb
->filterByContextIds(1)
->getQuery();
$result = DAORegistry::getDAO('PublicationDAO')->retrieveRange(
$qo->toSql(),
$qo->getBindings(),
new DBResultRange(20, null, 0);
);
$queryResults = new DAOResultFactory($result, $publicationDao, '_fromRow');
$iteratorOfObjects = $queryResults->toIterator();

Laravel's other query builder methods, such as first and pluck, can also be used.

$qb = new \PKP\Services\QueryBuilders\PublicationQueryBuilder();
$result = $qb
->filterByContextIds(1)
->getQuery()
->first();

See: https://laravel.com/docs/5.5/queries

Returns
Illuminate\Database\Query\Builder

Implements PKP\Services\QueryBuilders\Interfaces\EntityQueryBuilderInterface.

Definition at line 154 of file PKPContextQueryBuilder.inc.php.

References HookRegistry\call(), and PKP\Services\QueryBuilders\PKPContextQueryBuilder\searchPhrase().

◆ searchPhrase()

PKP\Services\QueryBuilders\PKPContextQueryBuilder::searchPhrase (   $phrase)

Set query search phrase

Parameters
$phrasestring
Returns
\PKP\Services\QueryBuilders\PKPContextQueryBuilder

Definition at line 93 of file PKPContextQueryBuilder.inc.php.

Referenced by PKP\Services\QueryBuilders\PKPContextQueryBuilder\getQuery().

Field Documentation

◆ $db

string PKPContextQueryBuilder::$db
protected

The database name for this context: journals or presses

Definition at line 26 of file PKPContextQueryBuilder.inc.php.

◆ $dbIdColumn

string PKPContextQueryBuilder::$dbIdColumn
protected

The column name for a context ID: journal_id or press_id

Definition at line 38 of file PKPContextQueryBuilder.inc.php.

◆ $dbSettings

string PKPContextQueryBuilder::$dbSettings
protected

The database name for this context's settings: journal_settings or press_settings

Definition at line 32 of file PKPContextQueryBuilder.inc.php.

◆ $isEnabled

boolean PKPContextQueryBuilder::$isEnabled = null
protected

enabled or disabled contexts

Definition at line 44 of file PKPContextQueryBuilder.inc.php.

Referenced by PKP\Services\QueryBuilders\PKPContextQueryBuilder\filterByIsEnabled().

◆ $searchPhrase

string PKPContextQueryBuilder::$searchPhrase = null
protected

search phrase

Definition at line 56 of file PKPContextQueryBuilder.inc.php.

◆ $userId

integer PKPContextQueryBuilder::$userId
protected

Filter contexts by whether or not this user can access it when logged in

Definition at line 50 of file PKPContextQueryBuilder.inc.php.

Referenced by PKP\Services\QueryBuilders\PKPContextQueryBuilder\filterByUserId().


The documentation for this class was generated from the following file:
DBResultRange
Container class for range information when retrieving a result set.
Definition: DBResultRange.inc.php:17
DAOResultFactory
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
Definition: DAOResultFactory.inc.php:21
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57