Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
DBAccessObjectUtils.php
Go to the documentation of this file.
1<?php
10namespaceWikimedia\Rdbms;
11
12use InvalidArgumentException;
13
19classDBAccessObjectUtilsimplementsIDBAccessObject {
25publicstaticfunctionhasFlags( $bitfield, $flags ) {
26return ( $bitfield & $flags ) == $flags;
27 }
28
38publicstaticfunctiongetDBOptions( $bitfield ) {
39wfDeprecated( __METHOD__,'1.43' );
40if ( self::hasFlags( $bitfield,IDBAccessObject::READ_LATEST_IMMUTABLE ) ) {
41 $index =DB_REPLICA;// override READ_LATEST if set
42 } elseif ( self::hasFlags( $bitfield,IDBAccessObject::READ_LATEST ) ) {
43 $index =DB_PRIMARY;
44 }else {
45 $index =DB_REPLICA;
46 }
47
48 $lockingOptions = [];
49if ( self::hasFlags( $bitfield,IDBAccessObject::READ_EXCLUSIVE ) ) {
50 $lockingOptions[] ='FOR UPDATE';
51 } elseif ( self::hasFlags( $bitfield,IDBAccessObject::READ_LOCKING ) ) {
52 $lockingOptions[] ='LOCK IN SHARE MODE';
53 }
54
55return [ $index, $lockingOptions ];
56 }
57
67publicstaticfunctiongetDBFromIndex(IConnectionProvider $dbProvider,int $index ):IReadableDatabase {
68wfDeprecated( __METHOD__,'1.42' );
69if ( $index ===DB_PRIMARY ) {
70return $dbProvider->getPrimaryDatabase();
71 } elseif ( $index ===DB_REPLICA ) {
72return $dbProvider->getReplicaDatabase();
73 }else {
74thrownew InvalidArgumentException('$index must be either DB_REPLICA or DB_PRIMARY' );
75 }
76 }
77
84publicstaticfunctiongetDBFromRecency(IConnectionProvider $dbProvider,int $recency ):IReadableDatabase {
85if ( self::hasFlags( $recency,IDBAccessObject::READ_LATEST ) ) {
86return $dbProvider->getPrimaryDatabase();
87 }
88return $dbProvider->getReplicaDatabase();
89 }
90}
91
93class_alias( DBAccessObjectUtils::class,'DBAccessObjectUtils' );
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
DefinitionGlobalFunctions.php:735
DB_REPLICA
const DB_REPLICA
Definitiondefines.php:26
DB_PRIMARY
const DB_PRIMARY
Definitiondefines.php:28
if
if(!defined('MW_SETUP_CALLBACK'))
DefinitionWebStart.php:68
Wikimedia\Rdbms\DBAccessObjectUtils
Helper class for DAO classes.
DefinitionDBAccessObjectUtils.php:19
Wikimedia\Rdbms\DBAccessObjectUtils\getDBFromIndex
static getDBFromIndex(IConnectionProvider $dbProvider, int $index)
Takes $index from ::getDBOptions() and return proper Database object.
DefinitionDBAccessObjectUtils.php:67
Wikimedia\Rdbms\DBAccessObjectUtils\hasFlags
static hasFlags( $bitfield, $flags)
DefinitionDBAccessObjectUtils.php:25
Wikimedia\Rdbms\DBAccessObjectUtils\getDBOptions
static getDBOptions( $bitfield)
Get an appropriate DB index and options.
DefinitionDBAccessObjectUtils.php:38
Wikimedia\Rdbms\DBAccessObjectUtils\getDBFromRecency
static getDBFromRecency(IConnectionProvider $dbProvider, int $recency)
DefinitionDBAccessObjectUtils.php:84
Wikimedia\Rdbms\IConnectionProvider
Provide primary and replica IDatabase connections.
DefinitionIConnectionProvider.php:21
Wikimedia\Rdbms\IConnectionProvider\getReplicaDatabase
getReplicaDatabase(string|false $domain=false, $group=null)
Get connection to a replica database.
Wikimedia\Rdbms\IConnectionProvider\getPrimaryDatabase
getPrimaryDatabase( $domain=false)
Get connection to the primary database.
Wikimedia\Rdbms\IDBAccessObject
Interface for database access objects.
DefinitionIDBAccessObject.php:45
Wikimedia\Rdbms\IDBAccessObject\READ_LATEST
const READ_LATEST
Read from the primary/quorum.
DefinitionIDBAccessObject.php:51
Wikimedia\Rdbms\IDBAccessObject\READ_LOCKING
const READ_LOCKING
Read from the primary/quorum and lock out other writers.
DefinitionIDBAccessObject.php:54
Wikimedia\Rdbms\IDBAccessObject\READ_LATEST_IMMUTABLE
const READ_LATEST_IMMUTABLE
Read from a replica DB or without a quorum, using the primary/quorum on miss.
DefinitionIDBAccessObject.php:60
Wikimedia\Rdbms\IDBAccessObject\READ_EXCLUSIVE
const READ_EXCLUSIVE
Read from the primary/quorum and lock out other writers and locking readers.
DefinitionIDBAccessObject.php:57
Wikimedia\Rdbms\IReadableDatabase
A database connection without write operations.
DefinitionIReadableDatabase.php:20
Wikimedia\Rdbms
DefinitionChangedTablesTracker.php:3

[8]ページ先頭

©2009-2025 Movatter.jp