Record
class Record implements ArrayAccess (View source)
Represents data loaded from a database.
Constants
STATE_INSERT |
A record state when new record is being inserted to database |
STATE_UPDATE |
A record state when existing record is being updated in the database |
STATE_DELETE |
A record state when the record no longer exists in the database |
Methods
Returns the primary key for the record as it was at the time the record was loaded.
Tells if the record is empty, i.e. none of the fields have any values.
Tells if the record is new and not yet inserted into the database.
Tells if the record has been deleted from the database.
Updates the state of the record after the appropriate database operation.
Returns the model associated with the record and initializes it if has not been initialized yet.
Tells if the referenced records for the given relationship has been loaded.
Loads the referenced records for the given relationship.
Returns the list of referenced records for the given relationship.
Sets the referencing fields in the record of the given model to reference this record.
Returns the model of the referenced record in a unique relationship.
Returns list of models referenced by this record via the given relationship.
Gets list of models that are referenced by records that this record references.
Returns list of records recursively referenced by this record or any referenced record.
Sets the values for the fields in the record loaded from the database.
Returns the values for the fields in this record for storing in database.
Returns list of all fields that have been modified since the records state was last updated.
Tells if the value in the given field is other than null.
Returns the value for the given field.
Sets the value for the given field.
Sets the value of the given field to null and marks it unchanged, if the record has not yet been inserted.
Details
at line 65
array
getPrimaryKey()
Returns the primary key for the record as it was at the time the record was loaded.
at line 78
bool
isEmpty()
Tells if the record is empty, i.e. none of the fields have any values.
at line 93
bool
isNew()
Tells if the record is new and not yet inserted into the database.
at line 102
bool
isDeleted()
Tells if the record has been deleted from the database.
at line 111
void
updateState(int $state)
Updates the state of the record after the appropriate database operation.
at line 144
Model
getModel()
Returns the model associated with the record and initializes it if has not been initialized yet.
at line 158
bool
hasReferencedRecords(string $name)
Tells if the referenced records for the given relationship has been loaded.
at line 170
void
setReferencedRecords(string $name, array $records)
Loads the referenced records for the given relationship.
at line 184
array
getReferencedRecords(string $name)
Returns the list of referenced records for the given relationship.
at line 200
void
associate(string $name, Model $model)
Sets the referenced fields in this record to reference the record of the given model.
at line 241
void
addAssociation(string $name, Model $model)
Sets the referencing fields in the record of the given model to reference this record.
at line 257
Model|null
getRelatedModel(string $name)
Returns the model of the referenced record in a unique relationship.
at line 279
array
getRelatedModels(string $name)
Returns list of models referenced by this record via the given relationship.
at line 302
array
getRelatedModelsByProxy(string $proxy, string $name)
Gets list of models that are referenced by records that this record references.
at line 334
array
getAllReferencedRecords()
Returns list of records recursively referenced by this record or any referenced record.
at line 358
void
setDatabaseValues(array $row)
Sets the values for the fields in the record loaded from the database.
at line 378
array
getDatabaseValues()
Returns the values for the fields in this record for storing in database.
at line 387
array
getChangedFields()
Returns list of all fields that have been modified since the records state was last updated.
at line 397
bool
offsetExists(string $offset)
Tells if the value in the given field is other than null.
at line 407
mixed
offsetGet(string $offset)
Returns the value for the given field.
at line 423
offsetSet(string $offset, mixed $value)
Sets the value for the given field.
at line 439
offsetUnset(string $offset)
Sets the value of the given field to null and marks it unchanged, if the record has not yet been inserted.