Abstract Class Misago\ActiveRecord\Record

Generic Record.

Dirty objects

You may track attribute changes.

Has a model changed?

$product = new Product(array('title' => 'qwerty'));;
$product->changed          # => false 

Change an attribute:

$product->title = 'azerty'
$product->changed          # => true
$product->title_changed    # => true
$product->title_was        # => 'qwerty'
$product->title_change     # => array('qwerty', 'azerty')
$product->title = 'swerty'
$product->title_change     # => array('qwerty', 'swerty') 

Saving resets contexts:

$product->save()
$product->changed          # => false
$product->title_changed    # => false 

Assigning identical values keeps the record unchanged.

$product->title = 'swerty'
$product->changed          # => false
$product->title_changed    # => false
$product->title_change     # => null 

Inheritence

Extends:
Misago
Implements:
ArrayAccess IteratorAggregate

Protected static attributes

Methods

Public static methods

column_for_attribute($attribute)

Returns the column definition for an attribute;

column_names()

Returns an array of column names.

columns()

has_column($column_name)

Checks if a column exists.

Public instance methods

__construct($attributes=null)

attribute_names()

attributes()

Returns current attributes.

changed()

Has any attribute changed?

changed_attributes()

List of attributes with unsaved changes.

changes()

Returns the list of changed attributes, with associated values.

getIterator()

has_attribute($attribute)

offsetExists($offset)

offsetGet($offset)

offsetSet($offset, $value)

offsetUnset($offset)

to_array()

Exports the record as array.

to_json()

Exports the record as JSON.

to_xml()

Exports the record as XML.

to_yaml()

Exports the record as YAML.