Semantic MediaWiki and related extensions
Public Member Functions | List of all members
SMW\MediaWiki\Database Class Reference

Public Member Functions

 __construct (DBConnectionProvider $readConnectionProvider, DBConnectionProvider $writeConnectionProvider=null, $loadBalancerFactory=null)
 
 isType ($type)
 
 getType ()
 
 setDBPrefix ($dbPrefix)
 
 tableName ($tableName)
 
 timestamp ($ts=0)
 
 addQuotes ($value)
 
 fetchObject ($res)
 
 numRows ($results)
 
 freeResult ($res)
 
 select ($tableName, $fields, $conditions= '', $fname, array $options=array(), $joinConditions=array())
 
 query ($sql, $fname=__METHOD__, $ignoreException=false, $withAutoCommit=false)
 
 selectRow ($table, $vars, $conds, $fname=__METHOD__, $options=array(), $joinConditions=array())
 
 affectedRows ()
 
 makeSelectOptions ($options)
 
 nextSequenceValue ($seqName)
 
 insertId ()
 
 resetTransactionProfiler ($resetTransactionProfiler)
 
 clearFlag ($flag)
 
 getFlag ($flag)
 
 setFlag ($flag)
 
 insert ($table, $rows, $fname=__METHOD__, $options=array())
 
 update ($table, $values, $conds, $fname=__METHOD__, $options=array())
 
 delete ($table, $conds, $fname=__METHOD__)
 
 replace ($table, $uniqueIndexes, $rows, $fname=__METHOD__)
 
 makeList ($data, $mode)
 
 tableExists ($table, $fname=__METHOD__)
 
 selectField ($table, $fieldName, $conditions= '', $fname=__METHOD__, $options=array())
 
 estimateRowCount ($table, $vars= '*', $conditions= '', $fname=__METHOD__, $options=array())
 
 getEmptyTransactionTicket ($fname=__METHOD__)
 
 commitAndWaitForReplication ($fname, $ticket, array $opts=[])
 
 beginAtomicTransaction ($fname=__METHOD__)
 
 endAtomicTransaction ($fname=__METHOD__)
 
 onTransactionIdle ($callback)
 

Detailed Description

This adapter class covers MW DB specific operations. Changes to the interface are likely therefore this class should not be used other than by SMW itself.

GNU GPL v2+

Since
1.9
Author
mwjames

Constructor & Destructor Documentation

SMW\MediaWiki\Database::__construct ( DBConnectionProvider  $readConnectionProvider,
DBConnectionProvider  $writeConnectionProvider = null,
  $loadBalancerFactory = null 
)
Since
1.9
Parameters
DBConnectionProvider$readConnectionProvider
DBConnectionProvider | null$writeConnectionProvider
ILBFactory | null$loadBalancerFactory

Member Function Documentation

SMW\MediaWiki\Database::addQuotes (   $value)
See also
DatabaseBase::addQuotes
Since
1.9.0.2
Parameters
string$tableName
Returns
string
SMW\MediaWiki\Database::affectedRows ( )
See also
DatabaseBase::affectedRows
Since
1.9.1
Returns
int
SMW\MediaWiki\Database::beginAtomicTransaction (   $fname = __METHOD__)
Since
2.3
Parameters
string$fname
SMW\MediaWiki\Database::clearFlag (   $flag)
See also
DatabaseBase::clearFlag
Since
2.4
SMW\MediaWiki\Database::commitAndWaitForReplication (   $fname,
  $ticket,
array  $opts = [] 
)

Convenience method for safely running commitMasterChanges/waitForReplication where it will allow to commit and wait for whena TransactionTicket is available.

Note
Only supported with 1.28+
Since
3.0
Parameters
string$fnameCaller name (e.g. METHOD)
mixed$ticketResult of Database::getEmptyTransactionTicket
array$optsOptions to waitForReplication
SMW\MediaWiki\Database::delete (   $table,
  $conds,
  $fname = __METHOD__ 
)
See also
DatabaseBase::delete
Since
1.9.1
SMW\MediaWiki\Database::endAtomicTransaction (   $fname = __METHOD__)
Since
2.3
Parameters
string$fname
SMW\MediaWiki\Database::estimateRowCount (   $table,
  $vars = '*',
  $conditions = '',
  $fname = __METHOD__,
  $options = array() 
)
See also
DatabaseBase::estimateRowCount
Since
2.1
SMW\MediaWiki\Database::fetchObject (   $res)
See also
DatabaseBase::fetchObject
Since
1.9.1
Parameters
ResultWrapper$res
Returns
string
SMW\MediaWiki\Database::freeResult (   $res)
See also
DatabaseBase::freeResult
Since
1.9.0.2
Parameters
ResultWrapper$res
SMW\MediaWiki\Database::getEmptyTransactionTicket (   $fname = __METHOD__)
Note
Only supported with 1.28+
Since
3.0
Parameters
string$fnameCaller name (e.g. METHOD)
Returns
mixed A value to pass to commitAndWaitForReplication
SMW\MediaWiki\Database::getFlag (   $flag)
See also
DatabaseBase::getFlag
Since
2.4
SMW\MediaWiki\Database::getType ( )
See also
DatabaseBase::getType
Since
1.9.1
Returns
string
SMW\MediaWiki\Database::insert (   $table,
  $rows,
  $fname = __METHOD__,
  $options = array() 
)
See also
DatabaseBase::insert
Since
1.9.1
SMW\MediaWiki\Database::insertId ( )
See also
DatabaseBase::insertId
Since
1.9.1
Returns
int
SMW\MediaWiki\Database::isType (   $type)
Since
2.5
Parameters
string$type
Returns
boolean
SMW\MediaWiki\Database::makeList (   $data,
  $mode 
)
See also
DatabaseBase::makeList
Since
1.9.1
SMW\MediaWiki\Database::makeSelectOptions (   $options)
Note
Method was made protected in 1.28, hence the need for the DatabaseHelper that copies the functionality.
See also
DatabaseBase::makeSelectOptions
Since
1.9.1
Parameters
array$options
Returns
array
SMW\MediaWiki\Database::nextSequenceValue (   $seqName)
See also
DatabaseBase::nextSequenceValue
Since
1.9.1
Parameters
string$seqName
Returns
int|null
SMW\MediaWiki\Database::numRows (   $results)
See also
DatabaseBase::numRows
Since
1.9.0.2
Parameters
mixed$results
Returns
integer
SMW\MediaWiki\Database::onTransactionIdle (   $callback)
Since
2.3
Parameters
callable$callback
SMW\MediaWiki\Database::query (   $sql,
  $fname = __METHOD__,
  $ignoreException = false,
  $withAutoCommit = false 
)
See also
DatabaseBase::query
Note
WithAutoCommit (#1605 "... creating temporary tables in a transaction is not replication-safe and causes errors in MySQL 5.6. ...")
Since
1.9.1
Parameters
string$sql
string$fname
boolean$ignoreException
boolean$withAutoCommit
Returns
ResultWrapper
Exceptions
RuntimeException
SMW\MediaWiki\Database::replace (   $table,
  $uniqueIndexes,
  $rows,
  $fname = __METHOD__ 
)
See also
DatabaseBase::replace
Since
2.5
SMW\MediaWiki\Database::resetTransactionProfiler (   $resetTransactionProfiler)
Note
Use a blank trx profiler to ignore exceptions
Since
2.4
SMW\MediaWiki\Database::select (   $tableName,
  $fields,
  $conditions = '',
  $fname,
array  $options = array(),
  $joinConditions = array() 
)
See also
DatabaseBase::select
Since
1.9.0.2
Parameters
string$tableName
$fields
$conditions
array$options
array$joinConditions
Returns
ResultWrapper
Exceptions
UnexpectedValueException
SMW\MediaWiki\Database::selectField (   $table,
  $fieldName,
  $conditions = '',
  $fname = __METHOD__,
  $options = array() 
)
See also
DatabaseBase::selectField
Since
1.9.2
SMW\MediaWiki\Database::selectRow (   $table,
  $vars,
  $conds,
  $fname = __METHOD__,
  $options = array(),
  $joinConditions = array() 
)
See also
DatabaseBase::selectRow
Since
1.9.1
SMW\MediaWiki\Database::setDBPrefix (   $dbPrefix)
Since
2.1
Parameters
string$dbPrefix
SMW\MediaWiki\Database::setFlag (   $flag)
See also
DatabaseBase::setFlag
Since
2.4
SMW\MediaWiki\Database::tableExists (   $table,
  $fname = __METHOD__ 
)
See also
DatabaseBase::tableExists
Since
1.9.1
Parameters
string$table
string$fname
Returns
bool
SMW\MediaWiki\Database::tableName (   $tableName)
See also
DatabaseBase::tableName
Since
1.9.0.2
Parameters
string$tableName
Returns
string
SMW\MediaWiki\Database::timestamp (   $ts = 0)
See also
DatabaseBase::timestamp
Since
3.0
Parameters
integer$ts
Returns
string
SMW\MediaWiki\Database::update (   $table,
  $values,
  $conds,
  $fname = __METHOD__,
  $options = array() 
)
See also
DatabaseBase::update
Since
1.9.1

The documentation for this class was generated from the following file: