[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/db/ -> ORMTable.php (summary)

(no description)

File Size: 1122 lines (26 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ORMTable:: (47 methods):
  __construct()
  getName()
  getFieldPrefix()
  getRowClass()
  getFields()
  getDefaults()
  getSummaryFields()
  select()
  selectObjects()
  rawSelect()
  selectFields()
  selectRow()
  rawSelectRow()
  selectFieldsRow()
  has()
  exists()
  count()
  delete()
  getAPIParams()
  getFieldDescriptions()
  getReadDb()
  setReadDb()
  getTargetWiki()
  setTargetWiki()
  getReadDbConnection()
  getWriteDbConnection()
  releaseConnection()
  update()
  updateSummaryFields()
  getPrefixedValues()
  getPrefixedFields()
  getPrefixedField()
  unprefixFieldNames()
  unprefixFieldName()
  singleton()
  getFieldsFromDBResult()
  newFromDBResult()
  newRowFromDBResult()
  newFromArray()
  newRow()
  getFieldNames()
  canHaveField()
  updateRow()
  insertRow()
  getWriteValues()
  removeRow()
  addToField()


Class: ORMTable  - X-Ref

Abstract base class for representing a single database table.
Documentation inline and at https://www.mediawiki.org/wiki/Manual:ORMTable

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
http://www.gnu.org/copyleft/gpl.html

__construct( $tableName = '', array $fields = array()   X-Ref
Constructor.

param: string $tableName
param: string[] $fields
param: array $defaults
param: string|null $rowClass
param: string $fieldPrefix

getName()   X-Ref

return: string

getFieldPrefix()   X-Ref
Gets the db field prefix.

return: string

getRowClass()   X-Ref

return: string

getFields()   X-Ref

return: array

getDefaults()   X-Ref
Returns a list of default field values.
field name => field value

return: array

getSummaryFields()   X-Ref
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.

return: array

select( $fields = null, array $conditions = array()   X-Ref
Selects the the specified fields of the records matching the provided
conditions and returns them as DBDataObject. Field names get prefixed.

param: array|string|null $fields
param: array $conditions
param: array $options
param: string|null $functionName
return: ORMResult

selectObjects( $fields = null, array $conditions = array()   X-Ref
Selects the the specified fields of the records matching the provided
conditions and returns them as DBDataObject. Field names get prefixed.

param: array|string|null $fields
param: array $conditions
param: array $options
param: string|null $functionName
return: array Array of row objects

rawSelect( $fields = null, array $conditions = array()   X-Ref
Do the actual select.

param: null|string|array $fields
param: array $conditions
param: array $options
param: null|string $functionName
return: ResultWrapper

selectFields( $fields = null, array $conditions = array()   X-Ref
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.

param: array|string|null $fields
param: array $conditions
param: array $options
param: bool $collapse Set to false to always return each result row as associative array.
param: string|null $functionName
return: array Array of array

selectRow( $fields = null, array $conditions = array()   X-Ref
Selects the the specified fields of the first matching record.
Field names get prefixed.

param: array|string|null $fields
param: array $conditions
param: array $options
param: string|null $functionName
return: IORMRow|bool False on failure

rawSelectRow( array $fields, array $conditions = array()   X-Ref
Selects the the specified fields of the records matching the provided
conditions. Field names do NOT get prefixed.

param: array $fields
param: array $conditions
param: array $options
param: string|null $functionName
return: stdClass

selectFieldsRow( $fields = null, array $conditions = array()   X-Ref
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).

param: array|string|null $fields
param: array $conditions
param: array $options
param: bool $collapse Set to false to always return each result row as associative array.
param: string|null $functionName
return: mixed|array|bool False on failure

has( array $conditions = array()   X-Ref
Returns if there is at least one record matching the provided conditions.
Condition field names get prefixed.

param: array $conditions
return: bool

exists()   X-Ref
Checks if the table exists

return: bool

count( array $conditions = array()   X-Ref
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.

param: array $conditions
param: array $options
return: int

delete( array $conditions, $functionName = null )   X-Ref
Removes the object from the database.

param: array $conditions
param: string|null $functionName
return: bool Success indicator

getAPIParams( $requireParams = false, $setDefaults = false )   X-Ref
Get API parameters for the fields supported by this object.

param: bool $requireParams
param: bool $setDefaults
return: array

getFieldDescriptions()   X-Ref
Returns an array with the fields and their descriptions.

field name => field description

return: array

getReadDb()   X-Ref
Get the database ID used for read operations.

return: int DB_ enum

setReadDb( $db )   X-Ref
Set the database ID to use for read operations, use DB_XXX constants or
an index to the load balancer setup.

param: int $db

getTargetWiki()   X-Ref
Get the ID of the any foreign wiki to use as a target for database operations

return: string|bool The target wiki, in a form that LBFactory understands

setTargetWiki( $wiki )   X-Ref
Set the ID of the any foreign wiki to use as a target for database operations

param: string|bool $wiki The target wiki, in a form that  LBFactory

getReadDbConnection()   X-Ref
Get the database type used for read operations.
This is to be used instead of wfGetDB.

return: DatabaseBase The database object

getWriteDbConnection()   X-Ref
Get the database type used for read operations.
This is to be used instead of wfGetDB.

return: DatabaseBase The database object

releaseConnection( DatabaseBase $db )   X-Ref
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.

param: DatabaseBase $db

update( array $values, array $conditions = array()   X-Ref
Update the records matching the provided conditions by
setting the fields that are keys in the $values param to
their corresponding values.

param: array $values
param: array $conditions
return: bool Success indicator

updateSummaryFields( $summaryFields = null, array $conditions = array()   X-Ref
Computes the values of the summary fields of the objects matching the provided conditions.

param: array|string|null $summaryFields
param: array $conditions

getPrefixedValues( array $values )   X-Ref
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.

param: array $values
return: array

getPrefixedFields( array $fields )   X-Ref
Takes in a field or array of fields and returns an
array with their prefixed versions, ready for db usage.

param: array $fields
return: array

getPrefixedField( $field )   X-Ref
Takes in a field and returns an it's prefixed version, ready for db usage.

param: string|array $field
return: string

unprefixFieldNames( array $fieldNames )   X-Ref
Takes an array of field names with prefix and returns the unprefixed equivalent.

param: array $fieldNames
return: array

unprefixFieldName( $fieldName )   X-Ref
Takes a field name with prefix and returns the unprefixed equivalent.

param: string $fieldName
return: string

singleton()   X-Ref
Get an instance of this class.

return: IORMTable

getFieldsFromDBResult( stdClass $result )   X-Ref
Get an array with fields from a database result,
that can be fed directly to the constructor or
to setFields.

param: stdClass $result
return: array

newFromDBResult( stdClass $result )   X-Ref

param: stdClass $result
return: IORMRow

newRowFromDBResult( stdClass $result )   X-Ref
Get a new instance of the class from a database result.

param: stdClass $result
return: IORMRow

newFromArray( array $data, $loadDefaults = false )   X-Ref

param: array $data
param: bool $loadDefaults
return: IORMRow

newRow( array $fields, $loadDefaults = false )   X-Ref
Get a new instance of the class from an array.

param: array $fields
param: bool $loadDefaults
return: IORMRow

getFieldNames()   X-Ref
Return the names of the fields.

return: array

canHaveField( $name )   X-Ref
Gets if the object can take a certain field.

param: string $name
return: bool

updateRow( IORMRow $row, $functionName = null )   X-Ref
Updates the provided row in the database.

param: IORMRow $row The row to save
param: string|null $functionName
return: bool Success indicator

insertRow( IORMRow $row, $functionName = null, array $options = null )   X-Ref
Inserts the provided row into the database.

param: IORMRow $row
param: string|null $functionName
param: array|null $options
return: bool Success indicator

getWriteValues( IORMRow $row )   X-Ref
Gets the fields => values to write to the table.

param: IORMRow $row
return: array

removeRow( IORMRow $row, $functionName = null )   X-Ref
Removes the provided row from the database.

param: IORMRow $row
param: string|null $functionName
return: bool Success indicator

addToField( array $conditions, $field, $amount )   X-Ref
Add an amount (can be negative) to the specified field (needs to be numeric).

param: array $conditions
param: string $field
param: int $amount
return: bool Success indicator



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1