MediaWiki  REL1_20
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 successfull 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 544 of file ORMRow.php.

ORMRow::beforeRemove ( ) [protected]

Gets called before an object is removed from the database.

Since:
1.20

Definition at line 427 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 630 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 440 of file ORMRow.php.

ORMRow::getField ( name,
default = null 
)

Gets the value of a field.

Since:
1.20
Parameters:
string$name
mixed$default
Exceptions:
MWException
Returns:
mixed

Implements IORMRow.

Definition at line 143 of file ORMRow.php.

Return the names of the fields.

Since:
1.20
Returns:
array

Implements IORMRow.

Definition at line 581 of file ORMRow.php.

Return the names and values of the fields.

Since:
1.20
Returns:
array

Implements IORMRow.

Definition at line 461 of file ORMRow.php.

Returns the objects database id.

Since:
1.20
Returns:
integer|null

Implements IORMRow.

Definition at line 188 of file ORMRow.php.

Return the names of the fields.

Since:
1.20
Returns:
array

Implements IORMRow.

Definition at line 472 of file ORMRow.php.

Returns the table this IORMRow is a row in.

Since:
1.20
Returns:
IORMTable

Implements IORMRow.

Definition at line 655 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 366 of file ORMRow.php.

ORMRow::getWriteValues ( ) [protected]

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

Since:
1.20
Returns:
array

Definition at line 251 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 212 of file ORMRow.php.

Gets if the id field is set.

Since:
1.20
Returns:
boolean

Implements IORMRow.

Definition at line 223 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 380 of file ORMRow.php.

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

Since:
1.20
Parameters:
string$name
Returns:
mixed

Implements IORMRow.

Definition at line 162 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 313 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 592 of file ORMRow.php.

ORMRow::onRemoved ( ) [protected]

Gets called after successfull removal.

Can be overriden to get rid of linked data.

Since:
1.20

Definition at line 450 of file ORMRow.php.

Removes the object from the database.

Since:
1.20
Returns:
boolean Success indicator

Implements IORMRow.

Definition at line 407 of file ORMRow.php.

ORMRow::removeField ( name)

Remove a field.

Since:
1.20
Parameters:
string$name

Implements IORMRow.

Definition at line 177 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 327 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 344 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 488 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 236 of file ORMRow.php.

ORMRow::setId ( id)

Sets the objects database id.

Since:
1.20
Parameters:
integer | null$id

Implements IORMRow.

Definition at line 199 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 614 of file ORMRow.php.

Sets the value for the.

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

Implements IORMRow.

Definition at line 603 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 283 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: