MediaWiki  1.23.6
IORMTable Interface Reference
Inheritance diagram for IORMTable:

Public Member Functions

 canHaveField ( $name)
 Gets if the object can take a certain field. More...
 
 count (array $conditions=array(), array $options=array())
 Returns the amount of matching records. More...
 
 delete (array $conditions, $functionName=null)
 Removes the object from the database. More...
 
 exists ()
 Checks if the table exists. More...
 
 getAPIParams ( $requireParams=false, $setDefaults=false)
 Get API parameters for the fields supported by this object. More...
 
 getDefaults ()
 Returns a list of default field values. More...
 
 getFieldDescriptions ()
 Returns an array with the fields and their descriptions. More...
 
 getFieldNames ()
 Return the names of the fields. More...
 
 getFields ()
 Returns an array with the fields and their types this object contains. More...
 
 getFieldsFromDBResult (stdClass $result)
 Get an array with fields from a database result, that can be fed directly to the constructor or to setFields. More...
 
 getLoadBalancer ()
 Get the database type used for read operations. More...
 
 getName ()
 Returns the name of the database table objects of this type are stored in. More...
 
 getPrefixedField ( $field)
 Takes in a field and returns an it's prefixed version, ready for db usage. More...
 
 getPrefixedFields (array $fields)
 Takes in a field or array of fields and returns an array with their prefixed versions, ready for db usage. More...
 
 getPrefixedValues (array $values)
 Takes in an associative array with field names as keys and their values as value. More...
 
 getReadDb ()
 Get the database type used for read operations. More...
 
 getReadDbConnection ()
 Get the database type used for read operations. More...
 
 getRowClass ()
 Returns the name of a IORMRow implementing class that represents single rows in this table. More...
 
 getSummaryFields ()
 Returns a list of the summary fields. More...
 
 getTargetWiki ()
 Get the ID of the any foreign wiki to use as a target for database operations. More...
 
 getWriteDbConnection ()
 Get the database type used for read operations. More...
 
 has (array $conditions=array())
 Returns if there is at least one record matching the provided conditions. More...
 
 newRow (array $data, $loadDefaults=false)
 Get a new instance of the class from an array. More...
 
 newRowFromDBResult (stdClass $result)
 Get a new instance of the class from a database result. More...
 
 rawSelect ( $fields=null, array $conditions=array(), array $options=array(), $functionName=null)
 Do the actual select. More...
 
 rawSelectRow (array $fields, array $conditions=array(), array $options=array(), $functionName=null)
 Selects the the specified fields of the records matching the provided conditions. More...
 
 releaseConnection (DatabaseBase $db)
 Releases the lease on the given database connection. More...
 
 select ( $fields=null, array $conditions=array(), array $options=array(), $functionName=null)
 Selects the the specified fields of the records matching the provided conditions and returns them as DBDataObject. More...
 
 selectFields ( $fields=null, array $conditions=array(), array $options=array(), $collapse=true, $functionName=null)
 Selects the the specified fields of the records matching the provided conditions and returns them as associative arrays. More...
 
 selectFieldsRow ( $fields=null, array $conditions=array(), array $options=array(), $collapse=true, $functionName=null)
 Selects the the specified fields of the first record matching the provided conditions and returns it as an associative array, or false when nothing matches. More...
 
 selectObjects ( $fields=null, array $conditions=array(), array $options=array(), $functionName=null)
 Selects the the specified fields of the records matching the provided conditions and returns them as DBDataObject. More...
 
 selectRow ( $fields=null, array $conditions=array(), array $options=array(), $functionName=null)
 Selects the the specified fields of the first matching record. More...
 
 setReadDb ( $db)
 Set the database type to use for read operations. More...
 
 setTargetWiki ( $wiki)
 Set the ID of the any foreign wiki to use as a target for database operations. More...
 
 unprefixFieldName ( $fieldName)
 Takes a field name with prefix and returns the unprefixed equivalent. More...
 
 unprefixFieldNames (array $fieldNames)
 Takes an array of field names with prefix and returns the unprefixed equivalent. More...
 
 update (array $values, array $conditions=array())
 Update the records matching the provided conditions by setting the fields that are keys in the $values param to their corresponding values. More...
 
 updateSummaryFields ( $summaryFields=null, array $conditions=array())
 Computes the values of the summary fields of the objects matching the provided conditions. More...
 

Detailed Description

Definition at line 30 of file IORMTable.php.

Member Function Documentation

◆ canHaveField()

IORMTable::canHaveField (   $name)

Gets if the object can take a certain field.

Since
1.20
Parameters
string$name
Returns
boolean

Implemented in ORMTable.

◆ count()

IORMTable::count ( array  $conditions = array(),
array  $options = array() 
)

Returns the amount of matching records.

Condition field names get prefixed.

Note that this can be expensive on large tables. In such cases you might want to use DatabaseBase::estimateRowCount instead.

Since
1.20
Parameters
array$conditions
array$options
Returns
integer

Implemented in ORMTable.

◆ delete()

IORMTable::delete ( array  $conditions,
  $functionName = null 
)

Removes the object from the database.

Since
1.20
Parameters
array$conditions
string | null$functionName
Returns
boolean Success indicator

Implemented in ORMTable.

◆ exists()

IORMTable::exists ( )

Checks if the table exists.

Since
1.21
Returns
boolean

Implemented in ORMTable.

◆ getAPIParams()

IORMTable::getAPIParams (   $requireParams = false,
  $setDefaults = false 
)

Get API parameters for the fields supported by this object.

Since
1.20
Parameters
boolean$requireParams
boolean$setDefaults
Returns
array

Implemented in ORMTable.

◆ getDefaults()

IORMTable::getDefaults ( )

Returns a list of default field values.

field name => field value

Since
1.20
Returns
array

Implemented in ORMTable.

◆ getFieldDescriptions()

IORMTable::getFieldDescriptions ( )

Returns an array with the fields and their descriptions.

field name => field description

Since
1.20
Returns
array

Implemented in ORMTable.

◆ getFieldNames()

IORMTable::getFieldNames ( )

Return the names of the fields.

Since
1.20
Returns
array

Implemented in ORMTable.

◆ getFields()

IORMTable::getFields ( )

Returns an array with the fields and their types this object contains.

This corresponds directly to the fields in the database, without prefix.

field name => type

Allowed types:

  • id
  • str
  • int
  • float
  • bool
  • array
  • blob

    Todo:
    Get rid of the id field. Every row instance needs to have one so this is just causing hassle at various locations by requiring an extra check for field name.
Since
1.20
Returns
array

Implemented in TestORMTable, ORMTable, and PageORMTableForTesting.

◆ getFieldsFromDBResult()

IORMTable::getFieldsFromDBResult ( stdClass  $result)

Get an array with fields from a database result, that can be fed directly to the constructor or to setFields.

Since
1.20
Parameters
stdClass$result
Returns
array

Implemented in ORMTable.

◆ getLoadBalancer()

IORMTable::getLoadBalancer ( )

Get the database type used for read operations.

See also
wfGetLB
Since
1.20
Returns
LoadBalancer The database load balancer object

◆ getName()

IORMTable::getName ( )

Returns the name of the database table objects of this type are stored in.

Since
1.20
Returns
string

Implemented in TestORMTable, ORMTable, and PageORMTableForTesting.

◆ getPrefixedField()

IORMTable::getPrefixedField (   $field)

Takes in a field and returns an it's prefixed version, ready for db usage.

Since
1.20
Parameters
string | array$field
Returns
string

Implemented in ORMTable.

◆ getPrefixedFields()

IORMTable::getPrefixedFields ( array  $fields)

Takes in a field or array of fields and returns an array with their prefixed versions, ready for db usage.

Since
1.20
Parameters
array | string$fields
Returns
array

Implemented in ORMTable.

◆ getPrefixedValues()

IORMTable::getPrefixedValues ( array  $values)

Takes in an associative array with field names as keys and their values as value.

The field names are prefixed with the db field prefix.

Since
1.20
Parameters
array$values
Returns
array

Implemented in ORMTable.

◆ getReadDb()

IORMTable::getReadDb ( )

Get the database type used for read operations.

Since
1.20
Returns
integer DB_ enum

Implemented in ORMTable.

◆ getReadDbConnection()

IORMTable::getReadDbConnection ( )

Get the database type used for read operations.

This is to be used instead of wfGetDB.

See also
LoadBalancer::getConnection
Since
1.20
Returns
DatabaseBase The database object

Implemented in ORMTable.

◆ getRowClass()

IORMTable::getRowClass ( )

Returns the name of a IORMRow implementing class that represents single rows in this table.

Since
1.20
Returns
string

Implemented in TestORMTable, ORMTable, and PageORMTableForTesting.

◆ getSummaryFields()

IORMTable::getSummaryFields ( )

Returns a list of the summary fields.

These are fields that cache computed values, such as the amount of linked objects of $type. This is relevant as one might not want to do actions such as log changes when these get updated.

Since
1.20
Returns
array

Implemented in ORMTable.

◆ getTargetWiki()

IORMTable::getTargetWiki ( )

Get the ID of the any foreign wiki to use as a target for database operations.

Since
1.20
Returns
String|bool The target wiki, in a form that LBFactory understands (or false if the local wiki is used)

Implemented in ORMTable.

◆ getWriteDbConnection()

IORMTable::getWriteDbConnection ( )

Get the database type used for read operations.

This is to be used instead of wfGetDB.

See also
LoadBalancer::getConnection
Since
1.20
Returns
DatabaseBase The database object

Implemented in ORMTable.

◆ has()

IORMTable::has ( array  $conditions = array())

Returns if there is at least one record matching the provided conditions.

Condition field names get prefixed.

Since
1.20
Parameters
array$conditions
Returns
boolean

Implemented in ORMTable.

◆ newRow()

IORMTable::newRow ( array  $data,
  $loadDefaults = false 
)

Get a new instance of the class from an array.

Since
1.20
Parameters
array$data
boolean$loadDefaults
Returns
IORMRow

Implemented in ORMTable, and PageORMTableForTesting.

◆ newRowFromDBResult()

IORMTable::newRowFromDBResult ( stdClass  $result)

Get a new instance of the class from a database result.

Since
1.20
Parameters
stdClass$result
Returns
IORMRow

Implemented in ORMTable.

◆ rawSelect()

IORMTable::rawSelect (   $fields = null,
array  $conditions = array(),
array  $options = array(),
  $functionName = null 
)

Do the actual select.

Since
1.20
Parameters
null | string | array$fields
array$conditions
array$options
null | string$functionName
Returns
ResultWrapper
Exceptions
DBQueryErrorif the query failed (even if the database was in ignoreErrors mode)

Implemented in ORMTable.

◆ rawSelectRow()

IORMTable::rawSelectRow ( array  $fields,
array  $conditions = array(),
array  $options = array(),
  $functionName = null 
)

Selects the the specified fields of the records matching the provided conditions.

Field names do NOT get prefixed.

Since
1.20
Parameters
array$fields
array$conditions
array$options
string | null$functionName
Returns
ResultWrapper

Implemented in ORMTable.

◆ releaseConnection()

IORMTable::releaseConnection ( DatabaseBase  $db)

Releases the lease on the given database connection.

This is useful mainly for connections to a foreign wiki. It does nothing for connections to the local wiki.

See also
LoadBalancer::reuseConnection
Parameters
DatabaseBase$dbthe database
Since
1.20

Implemented in ORMTable.

◆ select()

IORMTable::select (   $fields = null,
array  $conditions = array(),
array  $options = array(),
  $functionName = null 
)

Selects the the specified fields of the records matching the provided conditions and returns them as DBDataObject.

Field names get prefixed.

See also
DatabaseBase::select()
Since
1.20
Parameters
array | string | null$fields
array$conditions
array$options
string | null$functionName
Returns
ORMResult The result set
Exceptions
DBQueryErrorif the query failed (even if the database was in ignoreErrors mode)

Implemented in ORMTable.

◆ selectFields()

IORMTable::selectFields (   $fields = null,
array  $conditions = array(),
array  $options = array(),
  $collapse = true,
  $functionName = null 
)

Selects the the specified fields of the records matching the provided conditions and returns them as associative arrays.

Provided field names get prefixed. Returned field names will not have a prefix.

When $collapse is true: If one field is selected, each item in the result array will be this field. If two fields are selected, each item in the result array will have as key the first field and as value the second field. If more then two fields are selected, each item will be an associative array.

Since
1.20
Parameters
array | string | null$fields
array$conditions
array$options
boolean$collapseSet to false to always return each result row as associative array.
string | null$functionName
Returns
array of array

Implemented in ORMTable.

◆ selectFieldsRow()

IORMTable::selectFieldsRow (   $fields = null,
array  $conditions = array(),
array  $options = array(),
  $collapse = true,
  $functionName = null 
)

Selects the the specified fields of the first record matching the provided conditions and returns it as an associative array, or false when nothing matches.

This method makes use of selectFields and expects the same parameters and returns the same results (if there are any, if there are none, this method returns false).

See also
IORMTable::selectFields
Since
1.20
Parameters
array | string | null$fields
array$conditions
array$options
boolean$collapseSet to false to always return each result row as associative array.
string | null$functionName
Returns
mixed|array|bool False on failure

Implemented in ORMTable.

◆ selectObjects()

IORMTable::selectObjects (   $fields = null,
array  $conditions = array(),
array  $options = array(),
  $functionName = null 
)

Selects the the specified fields of the records matching the provided conditions and returns them as DBDataObject.

Field names get prefixed.

Since
1.20
Parameters
array | string | null$fields
array$conditions
array$options
string | null$functionName
Returns
array of self

Implemented in ORMTable.

◆ selectRow()

IORMTable::selectRow (   $fields = null,
array  $conditions = array(),
array  $options = array(),
  $functionName = null 
)

Selects the the specified fields of the first matching record.

Field names get prefixed.

Since
1.20
Parameters
array | string | null$fields
array$conditions
array$options
string | null$functionName
Returns
IORMRow|bool False on failure

Implemented in ORMTable.

◆ setReadDb()

IORMTable::setReadDb (   $db)

Set the database type to use for read operations.

Parameters
integer$db
Since
1.20

Implemented in ORMTable.

◆ setTargetWiki()

IORMTable::setTargetWiki (   $wiki)

Set the ID of the any foreign wiki to use as a target for database operations.

Parameters
string | bool$wikiThe target wiki, in a form that LBFactory understands (or false if the local wiki shall be used)
Since
1.20

Implemented in ORMTable.

◆ unprefixFieldName()

IORMTable::unprefixFieldName (   $fieldName)

Takes a field name with prefix and returns the unprefixed equivalent.

Since
1.20
Parameters
string$fieldName
Returns
string

Implemented in ORMTable.

◆ unprefixFieldNames()

IORMTable::unprefixFieldNames ( array  $fieldNames)

Takes an array of field names with prefix and returns the unprefixed equivalent.

Since
1.20
Parameters
array$fieldNames
Returns
array

Implemented in ORMTable.

◆ update()

IORMTable::update ( array  $values,
array  $conditions = array() 
)

Update the records matching the provided conditions by setting the fields that are keys in the $values param to their corresponding values.

Since
1.20
Parameters
array$values
array$conditions
Returns
boolean Success indicator

Implemented in ORMTable.

◆ updateSummaryFields()

IORMTable::updateSummaryFields (   $summaryFields = null,
array  $conditions = array() 
)

Computes the values of the summary fields of the objects matching the provided conditions.

Since
1.20
Parameters
array | string | null$summaryFields
array$conditions

Implemented in ORMTable.


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