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

List of all members.

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Definition at line 34 of file ORMRow.php.


Constructor & Destructor Documentation

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

Constructor.

Since:
1.20
Parameters:
IORMTable$table
array | null$fields
boolean$loadDefaults

Implements IORMRow.

Definition at line 77 of file ORMRow.php.


Member Function Documentation

ORMRow::addToField ( field,
amount 
)

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

TODO: most off this stuff makes more sense in the table class

Since:
1.20
Parameters:
string$field
integer$amount
Returns:
boolean Success indicator

Implements IORMRow.

Definition at line 553 of file ORMRow.php.

ORMRow::beforeRemove ( ) [protected]

Gets called before an object is removed from the database.

Since:
1.20

Definition at line 440 of file ORMRow.php.

ORMRow::fieldsChanged ( IORMRow object,
excludeSummaryFields = false 
) [protected]

Return if any fields got changed.

Since:
1.20
Parameters:
IORMRow$object
boolean | array$excludeSummaryFieldsWhen set to true, summary field changes are ignored. Can also be an array of fields to ignore.
Returns:
boolean

Definition at line 641 of file ORMRow.php.

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 453 of file ORMRow.php.

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 145 of file ORMRow.php.

Return the names of the fields.

Since:
1.20
Returns:
array

Implements IORMRow.

Definition at line 592 of file ORMRow.php.

Return the names and values of the fields.

Since:
1.20
Returns:
array

Implements IORMRow.

Definition at line 474 of file ORMRow.php.

Returns the objects database id.

Since:
1.20
Returns:
integer|null

Implements IORMRow.

Definition at line 190 of file ORMRow.php.

Return the names of the fields.

Since:
1.20
Returns:
array

Implements IORMRow.

Definition at line 485 of file ORMRow.php.

Returns the table this IORMRow is a row in.

Since:
1.20
Returns:
IORMTable

Implements IORMRow.

Definition at line 666 of file ORMRow.php.

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 377 of file ORMRow.php.

ORMRow::getWriteValues ( ) [protected]

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

Since:
1.20
Returns:
array

Definition at line 253 of file ORMRow.php.

ORMRow::hasField ( name)

Gets if a certain field is set.

Since:
1.20
Parameters:
string$name
Returns:
boolean

Implements IORMRow.

Definition at line 214 of file ORMRow.php.

Gets if the id field is set.

Since:
1.20
Returns:
boolean

Implements IORMRow.

Definition at line 225 of file ORMRow.php.

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

Inserts the object into the database.

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

Definition at line 391 of file ORMRow.php.

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

Since:
1.20
Parameters:
$namestring
Returns:
mixed

Implements IORMRow.

Definition at line 164 of file ORMRow.php.

ORMRow::loadDefaults ( override = true)

Load the default values, via getDefaults.

Since:
1.20
Parameters:
boolean$override

Implements IORMRow.

Definition at line 322 of file ORMRow.php.

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

Load the specified fields from the database.

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

Implements IORMRow.

Definition at line 102 of file ORMRow.php.

ORMRow::loadSummaryFields ( summaryFields = null)

Computes and updates the values of the summary fields.

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

Implements IORMRow.

Definition at line 603 of file ORMRow.php.

ORMRow::onRemoved ( ) [protected]

Gets called after successful removal.

Can be overridden to get rid of linked data.

Since:
1.20

Definition at line 463 of file ORMRow.php.

Removes the object from the database.

Since:
1.20
Returns:
boolean Success indicator

Implements IORMRow.

Definition at line 420 of file ORMRow.php.

ORMRow::removeField ( name)

Remove a field.

Since:
1.20
Parameters:
string$name

Implements IORMRow.

Definition at line 179 of file ORMRow.php.

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
Parameters:
string | null$functionName
Returns:
boolean Success indicator

Implements IORMRow.

Definition at line 336 of file ORMRow.php.

ORMRow::saveExisting ( functionName = null) [protected]

Updates the object in the database.

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

Definition at line 353 of file ORMRow.php.

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 501 of file ORMRow.php.

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 238 of file ORMRow.php.

ORMRow::setId ( id)

Sets the objects database id.

Since:
1.20
Parameters:
integer | null$id

Implements IORMRow.

Definition at line 201 of file ORMRow.php.

ORMRow::setSummaryMode ( summaryMode)

Sets the value for the.

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

Implements IORMRow.

Definition at line 625 of file ORMRow.php.

Sets the value for the.

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

Implements IORMRow.

Definition at line 614 of file ORMRow.php.

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 292 of file ORMRow.php.


Member Data Documentation

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

The fields of the object.

field name (w/o prefix) => value

Since:
1.20

Definition at line 42 of file ORMRow.php.

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.

Since:
1.20

Definition at line 66 of file ORMRow.php.

ORMTable ORMRow::$table [protected]
Since:
1.20

Definition at line 47 of file ORMRow.php.

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.

Since:
1.20

Definition at line 57 of file ORMRow.php.


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