MediaWiki  1.23.2
ORMRow Class Reference
Inheritance diagram for ORMRow:
Collaboration diagram for ORMRow:

Public Member Functions

 __construct (IORMTable $table=null, $fields=null, $loadDefaults=false)
 Constructor. More...
 
 addToField ( $field, $amount)
 Add an amount (can be negative) to the specified field (needs to be numeric). More...
 
 getField ( $name, $default=null)
 Gets the value of a field. More...
 
 getFieldNames ()
 Return the names of the fields. More...
 
 getFields ()
 Return the names and values of the fields. More...
 
 getId ()
 Returns the objects database id. More...
 
 getSetFieldNames ()
 Return the names of the fields. More...
 
 getTable ()
 Returns the table this IORMRow is a row in. More...
 
 hasField ( $name)
 Gets if a certain field is set. More...
 
 hasIdField ()
 Gets if the id field is set. More...
 
 loadAndGetField ( $name)
 Gets the value of a field but first loads it if not done so already. More...
 
 loadDefaults ( $override=true)
 Load the default values, via getDefaults. More...
 
 loadFields ( $fields=null, $override=true, $skipLoaded=false)
 Load the specified fields from the database. More...
 
 loadSummaryFields ( $summaryFields=null)
 Computes and updates the values of the summary fields. More...
 
 remove ()
 Removes the object from the database. More...
 
 removeField ( $name)
 Remove a field. More...
 
 save ( $functionName=null)
 Writes the answer to the database, either updating it when it already exists, or inserting it when it doesn't. More...
 
 setField ( $name, $value)
 Sets the value of a field. More...
 
 setFields (array $fields, $override=true)
 Sets multiple fields. More...
 
 setId ( $id)
 Sets the objects database id. More...
 
 setSummaryMode ( $summaryMode)
 Sets the value for the. More...
 
 setUpdateSummaries ( $update)
 Sets the value for the. More...
 
 toArray ( $fields=null, $incNullId=false)
 Serializes the object to an associative array which can then easily be converted into JSON or similar. More...
 

Protected Member Functions

 beforeRemove ()
 Gets called before an object is removed from the database. More...
 
 getBeforeRemoveFields ()
 Before removal of an object happens,. More...
 
 getUpdateConditions ()
 Returns the WHERE considtions needed to identify this object so it can be updated. More...
 
 getWriteValues ()
 Gets the fields => values to write to the table. More...
 
 insert ( $functionName=null, array $options=null)
 Inserts the object into the database. More...
 
 onRemoved ()
 Gets called after successful removal. More...
 
 saveExisting ( $functionName=null)
 Updates the object in the database. More...
 

Protected Attributes

array $fields = array( 'id' => null )
 The fields of the object. More...
 
bool $inSummaryMode = false
 Indicates if the object is in summary mode. More...
 
ORMTable null $table
 
bool $updateSummaries = true
 If the object should update summaries of linked items when changed. More...
 

Detailed Description

Definition at line 34 of file ORMRow.php.

Constructor & Destructor Documentation

◆ __construct()

ORMRow::__construct ( IORMTable  $table = null,
  $fields = null,
  $loadDefaults = false 
)

Constructor.

Since
1.20
Parameters
IORMTable | null$tableDeprecated since 1.22
array | null$fields
boolean$loadDefaultsDeprecated since 1.22

Definition at line 79 of file ORMRow.php.

References $fields, $table, array(), setFields(), and table.

Member Function Documentation

◆ addToField()

ORMRow::addToField (   $field,
  $amount 
)

Add an amount (can be negative) to the specified field (needs to be numeric).

Since
1.20
Deprecated:
since 1.22, use IORMTable->addToField
Parameters
string$field
integer$amount
Returns
boolean Success indicator

Implements IORMRow.

Definition at line 527 of file ORMRow.php.

References getUpdateConditions(), and table.

◆ beforeRemove()

ORMRow::beforeRemove ( )
protected

Gets called before an object is removed from the database.

Since
1.20
Deprecated:
since 1.22

Definition at line 449 of file ORMRow.php.

References getBeforeRemoveFields(), and loadFields().

Referenced by remove().

◆ getBeforeRemoveFields()

ORMRow::getBeforeRemoveFields ( )
protected

Before removal of an object happens,.

See also
beforeRemove gets called. This method loads the fields of which the names have been returned by this one (or all fields if null is returned). This allows for loading info needed after removal to get rid of linked data and the like.
Since
1.20
Returns
array|null

Definition at line 463 of file ORMRow.php.

References array().

Referenced by beforeRemove().

◆ getField()

ORMRow::getField (   $name,
  $default = null 
)

Gets the value of a field.

Since
1.20
Parameters
string$nameField name
$defaultmixed: Default value to return when none is found (default: null)
Exceptions
MWException
Returns
mixed

Implements IORMRow.

Definition at line 150 of file ORMRow.php.

References $name, and hasField().

Referenced by getId(), hasIdField(), loadAndGetField(), SiteSQLStore\siteFromRow(), and toArray().

◆ getFieldNames()

ORMRow::getFieldNames ( )

Return the names of the fields.

Since
1.20
Deprecated:
since 1.22
Returns
array

Implements IORMRow.

Definition at line 539 of file ORMRow.php.

References table.

◆ getFields()

ORMRow::getFields ( )

Return the names and values of the fields.

Since
1.20
Returns
array

Implements IORMRow.

Definition at line 485 of file ORMRow.php.

References $fields.

◆ getId()

ORMRow::getId ( )

Returns the objects database id.

Since
1.20
Returns
integer|null

Implements IORMRow.

Definition at line 196 of file ORMRow.php.

References getField().

Referenced by getUpdateConditions(), and loadFields().

◆ getSetFieldNames()

ORMRow::getSetFieldNames ( )

Return the names of the fields.

Since
1.20
Returns
array

Implements IORMRow.

Definition at line 496 of file ORMRow.php.

Referenced by toArray().

◆ getTable()

ORMRow::getTable ( )

Returns the table this IORMRow is a row in.

Since
1.20
Deprecated:
since 1.22
Returns
IORMTable

Implements IORMRow.

Definition at line 586 of file ORMRow.php.

References $table.

◆ getUpdateConditions()

ORMRow::getUpdateConditions ( )
protected

Returns the WHERE considtions needed to identify this object so it can be updated.

Since
1.20
Returns
array

Definition at line 386 of file ORMRow.php.

References array(), and getId().

Referenced by addToField(), and saveExisting().

◆ getWriteValues()

ORMRow::getWriteValues ( )
protected

Gets the fields => values to write to the table.

Since
1.20
Deprecated:
since 1.22
Returns
array

Definition at line 243 of file ORMRow.php.

References $name, $type, $value, array(), as, and table.

Referenced by insert(), and saveExisting().

◆ hasField()

ORMRow::hasField (   $name)

Gets if a certain field is set.

Since
1.20
Parameters
string$name
Returns
boolean

Implements IORMRow.

Definition at line 220 of file ORMRow.php.

References $name.

Referenced by getField(), hasIdField(), loadAndGetField(), setFields(), SiteSQLStore\siteFromRow(), and toArray().

◆ hasIdField()

ORMRow::hasIdField ( )

Gets if the id field is set.

Since
1.20
Returns
boolean

Implements IORMRow.

Definition at line 231 of file ORMRow.php.

References getField(), and hasField().

Referenced by save(), and toArray().

◆ insert()

ORMRow::insert (   $functionName = null,
array  $options = null 
)
protected

Inserts the object into the database.

Since
1.20
Deprecated:
since 1.22
Parameters
string | null$functionName
array | null$options
Returns
boolean Success indicator

Definition at line 401 of file ORMRow.php.

References $options, $success, getWriteValues(), setField(), and table.

◆ loadAndGetField()

ORMRow::loadAndGetField (   $name)

Gets the value of a field but first loads it if not done so already.

Since
1.20
Deprecated:
since 1.22
Parameters
$namestring
Returns
mixed

Implements IORMRow.

Definition at line 170 of file ORMRow.php.

References $name, array(), getField(), hasField(), and loadFields().

◆ loadDefaults()

ORMRow::loadDefaults (   $override = true)

Load the default values, via getDefaults.

Since
1.20
Deprecated:
since 1.22
Parameters
boolean$override

Implements IORMRow.

Definition at line 329 of file ORMRow.php.

References setFields(), and table.

◆ loadFields()

ORMRow::loadFields (   $fields = null,
  $override = true,
  $skipLoaded = false 
)

Load the specified fields from the database.

Since
1.20
Deprecated:
since 1.22
Parameters
array | null$fields
boolean$override
boolean$skipLoaded
Returns
bool Success indicator

Implements IORMRow.

Definition at line 105 of file ORMRow.php.

References $fields, array(), getId(), setFields(), and table.

Referenced by beforeRemove(), and loadAndGetField().

◆ loadSummaryFields()

ORMRow::loadSummaryFields (   $summaryFields = null)

Computes and updates the values of the summary fields.

Since
1.20
Deprecated:
since 1.22
Parameters
array | string | null$summaryFields

Implements IORMRow.

Definition at line 551 of file ORMRow.php.

◆ onRemoved()

ORMRow::onRemoved ( )
protected

Gets called after successful removal.

Can be overridden to get rid of linked data.

Since
1.20
Deprecated:
since 1.22

Definition at line 474 of file ORMRow.php.

References setField().

Referenced by remove().

◆ remove()

ORMRow::remove ( )

Removes the object from the database.

Since
1.20
Deprecated:
since 1.22, use IORMTable->removeRow
Returns
boolean Success indicator

Implements IORMRow.

Definition at line 431 of file ORMRow.php.

References $success, beforeRemove(), onRemoved(), and table.

◆ removeField()

ORMRow::removeField (   $name)

Remove a field.

Since
1.20
Parameters
string$name

Implements IORMRow.

Definition at line 185 of file ORMRow.php.

References $name.

◆ save()

ORMRow::save (   $functionName = null)

Writes the answer to the database, either updating it when it already exists, or inserting it when it doesn't.

Since
1.20
Deprecated:
since 1.22 Use IORMTable->updateRow or ->insertRow
Parameters
string | null$functionName
Returns
boolean Success indicator

Implements IORMRow.

Definition at line 344 of file ORMRow.php.

References hasIdField(), and table.

◆ saveExisting()

ORMRow::saveExisting (   $functionName = null)
protected

Updates the object in the database.

Since
1.20
Deprecated:
since 1.22
Parameters
string | null$functionName
Returns
boolean Success indicator

Definition at line 362 of file ORMRow.php.

References $success, getUpdateConditions(), getWriteValues(), and table.

◆ setField()

ORMRow::setField (   $name,
  $value 
)

Sets the value of a field.

Strings can be provided for other types, so this method can be called from unserialization handlers.

Since
1.20
Parameters
string$name
mixed$value
Exceptions
MWException

Implements IORMRow.

Definition at line 512 of file ORMRow.php.

References $name, and $value.

Referenced by insert(), onRemoved(), setFields(), and setId().

◆ setFields()

ORMRow::setFields ( array  $fields,
  $override = true 
)

Sets multiple fields.

Since
1.20
Parameters
array$fieldsThe fields to set
boolean$overrideOverride already set fields with the provided values?

Implements IORMRow.

Definition at line 279 of file ORMRow.php.

References $fields, $name, $value, as, hasField(), and setField().

Referenced by __construct(), loadDefaults(), and loadFields().

◆ setId()

ORMRow::setId (   $id)

Sets the objects database id.

Since
1.20
Parameters
integer | null$id

Implements IORMRow.

Definition at line 207 of file ORMRow.php.

References setField().

◆ setSummaryMode()

ORMRow::setSummaryMode (   $summaryMode)

Sets the value for the.

See also
$inSummaryMode field.
Since
1.20
Deprecated:
since 1.22
Parameters
boolean$summaryMode

Implements IORMRow.

Definition at line 574 of file ORMRow.php.

◆ setUpdateSummaries()

ORMRow::setUpdateSummaries (   $update)

Sets the value for the.

See also
$updateSummaries field.
Since
1.20
Deprecated:
since 1.22
Parameters
boolean$update

Implements IORMRow.

Definition at line 562 of file ORMRow.php.

◆ toArray()

ORMRow::toArray (   $fields = null,
  $incNullId = false 
)

Serializes the object to an associative array which can then easily be converted into JSON or similar.

Since
1.20
Parameters
null | array$fields
boolean$incNullId
Returns
array

Implements IORMRow.

Definition at line 298 of file ORMRow.php.

References $fields, array(), as, getField(), getSetFieldNames(), hasField(), and hasIdField().

Member Data Documentation

◆ $fields

array ORMRow::$fields = array( 'id' => null )
protected

The fields of the object.

field name (w/o prefix) => value

Since
1.20

Definition at line 41 of file ORMRow.php.

Referenced by __construct(), getFields(), loadFields(), setFields(), and toArray().

◆ $inSummaryMode

bool ORMRow::$inSummaryMode = false
protected

Indicates if the object is in summary mode.

This mode indicates that only summary fields got updated, which allows for optimizations.

Deprecated:
since 1.22
Since
1.20

Definition at line 62 of file ORMRow.php.

◆ $table

ORMTable null ORMRow::$table
protected
Deprecated:
since 1.22
Since
1.20

Definition at line 68 of file ORMRow.php.

Referenced by __construct(), and getTable().

◆ $updateSummaries

bool ORMRow::$updateSummaries = true
protected

If the object should update summaries of linked items when changed.

For example, update the course_count field in universities when a course in courses is deleted. Settings this to false can prevent needless updating work in situations such as deleting a university, which will then delete all it's courses.

Deprecated:
since 1.22
Since
1.20

Definition at line 52 of file ORMRow.php.


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