StructureRecord

Type
Class
Namespace
Craft
Inherits
Craft\StructureRecord » Craft\BaseRecord » CActiveRecord (opens new window) » CModel (opens new window) » CComponent (opens new window)
Implements
ArrayAccess (opens new window), IteratorAggregate (opens new window)
Since
2.0

Class StructureRecord

See also http://craftcms.com

View source (opens new window)

# Public Properties

Property Description
$db (opens new window) CDbConnection (opens new window) – The default database connection for all active record classes.

# Protected Properties

Property Description
$_attributes (opens new window)

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__construct() Constructor
__get() (opens new window) Returns a property value, an event handler list or a behavior based on its name.
__isset() (opens new window) Checks if a property value is null.
__set() (opens new window) Sets value of a component property.
__sleep() (opens new window) PHP sleep magic method.
__unset() (opens new window) Sets a component property to be null.
addError() (opens new window) Adds a new error to the specified attribute.
addErrors() (opens new window) Adds a list of errors.
addForeignKeys() Adds foreign keys to the model's table.
addRelatedRecord() (opens new window) Do not call this method. This method is used internally by {@link CActiveFinder} to populate related objects. This method adds a related object to this record.
afterFindInternal() (opens new window) Calls {@link afterFind}.
applyScopes() (opens new window) Applies the query scopes to the given criteria.
asa() (opens new window) Returns the named behavior object.
attachBehavior() (opens new window) Attaches a behavior to this component.
attachBehaviors() (opens new window) Attaches a list of behaviors to the component.
attachEventHandler() (opens new window) Attaches an event handler to an event.
attributeLabels() Returns the attribute labels.
attributeNames() (opens new window) Returns the list of attribute names of the model.
beforeFindInternal() (opens new window) Calls {@link beforeFind}.
behaviors() (opens new window) Returns a list of behaviors that this model should behave as.
cache() (opens new window) Sets the parameters about query caching.
canGetProperty() (opens new window) Determines whether a property can be read.
canSetProperty() (opens new window) Determines whether a property can be set.
clearErrors() (opens new window) Removes errors for all attributes or a single attribute.
count() (opens new window) Finds the number of rows satisfying the specified query condition.
countByAttributes() (opens new window) Finds the number of rows that have the specified attribute values.
countBySql() (opens new window) Finds the number of rows using the given SQL statement.
createTable() Creates the model's table.
createValidators() (opens new window) Creates validator objects based on the specification in {@link rules}.
defaultScope() (opens new window) Returns the default named scope that should be implicitly applied to all queries for this model.
defineIndexes() Defines this model's database table indexes.
defineRelations() Defines this model's relations to other models.
delete() (opens new window) Deletes the row corresponding to this active record.
deleteAll() (opens new window) Deletes rows with the specified condition.
deleteAllByAttributes() (opens new window) Deletes rows which match the specified attribute values.
deleteByPk() (opens new window) Deletes rows with the specified primary key.
detachBehavior() (opens new window) Detaches a behavior from the component.
detachBehaviors() (opens new window) Detaches all behaviors from the component.
detachEventHandler() (opens new window) Detaches an existing event handler.
disableBehavior() (opens new window) Disables an attached behavior.
disableBehaviors() (opens new window) Disables all behaviors attached to this component.
dropForeignKeys() Drops the foreign keys from the model's table.
dropTable() Drops the model's table.
enableBehavior() (opens new window) Enables an attached behavior.
enableBehaviors() (opens new window) Enables all behaviors attached to this component.
equals() (opens new window) Compares current active record with another one.
evaluateExpression() (opens new window) Evaluates a PHP expression or callback under the context of this component.
exists() (opens new window) Checks whether there is row satisfying the specified condition.
find() (opens new window) Finds a single active record with the specified condition.
findAll() (opens new window) Finds all active records satisfying the specified condition.
findAllByAttributes() (opens new window) Finds all active records that have the specified attribute values.
findAllById()
findAllByPk() (opens new window) Finds all active records with the specified primary keys.
findAllBySql() (opens new window) Finds all active records using the specified SQL statement.
findByAttributes() (opens new window) Finds a single active record that has the specified attribute values.
findById()
findByPk() (opens new window) Finds a single active record with the specified primary key.
findBySql() (opens new window) Finds a single active record with the specified SQL statement.
generateAttributeLabel() (opens new window) Generates a user friendly attribute label.
getActiveFinder() (opens new window) Given 'with' options returns a new active finder instance.
getActiveRelation() (opens new window) Returns the named relation declared for this AR class.
getAttribute() (opens new window) Returns the named attribute value.
getAttributeConfigs() Returns this record's normalized attribute configs.
getAttributeLabel() (opens new window) Returns the text label for the specified attribute.
getAttributes() (opens new window) Returns all attribute values.
getBelongsToRelations() Returns the BELONGS_TO relations.
getCommandBuilder() (opens new window) Returns the command builder used by this AR.
getDbConnection() (opens new window) Returns the database connection used by active record.
getDbCriteria() (opens new window) Returns the query criteria associated with this model.
getError() (opens new window) Returns the first error of the specified attribute.
getErrors() (opens new window) Returns the errors for all attribute or a single attribute.
getEventHandlers() (opens new window) Returns the list of attached event handlers for an event.
getIsNewRecord() (opens new window) Returns if the current record is new (was never saved to database)
getIterator() (opens new window) Returns an iterator for traversing the attributes in the model.
getMetaData() (opens new window) Returns the meta-data for this AR
getOldPrimaryKey() (opens new window) Returns the old primary key value.
getPrimaryKey() (opens new window) Returns the primary key value.
getRelated() (opens new window) Returns the related record(s).
getSafeAttributeNames() (opens new window) Returns the attribute names that are safe to be massively assigned.
getScenario() (opens new window) Returns the scenario that this model is used in.
getTableAlias() (opens new window) Returns the table alias to be used by the find methods.
getTableName() Returns the name of the associated database table.
getTableSchema() (opens new window) Returns the metadata of the table that this AR belongs to
getValidatorList() (opens new window) Returns all the validators declared in the model.
getValidators() (opens new window) Returns the validators applicable to the current {@link scenario}.
hasAttribute() (opens new window) Checks whether this AR has the named attribute
hasErrors() (opens new window) Returns a value indicating whether there is any validation error.
hasEvent() (opens new window) Determines whether an event is defined.
hasEventHandler() (opens new window) Checks whether the named event has attached handlers.
hasProperty() (opens new window) Determines whether a property is defined.
hasRelated() (opens new window) Returns a value indicating whether the named related object(s) has been loaded.
init() Initializes the application component.
insert() (opens new window) Inserts a row into the table based on this active record attributes.
isAttributeRequired() (opens new window) Returns a value indicating whether the attribute is required.
isAttributeSafe() (opens new window) Returns a value indicating whether the attribute is safe for massive assignments.
isNewRecord()
model() Returns an instance of the specified model
offsetExists() (opens new window) Returns whether there is an element at the specified offset.
offsetGet() (opens new window) Returns the element at the specified offset.
offsetSet() (opens new window) Sets the element at the specified offset.
offsetUnset() (opens new window) Unsets the element at the specified offset.
onAfterConstruct() (opens new window) This event is raised after the model instance is created by new operator.
onAfterDelete() (opens new window) This event is raised after the record is deleted.
onAfterFind() (opens new window) This event is raised after the record is instantiated by a find method.
onAfterSave() (opens new window) This event is raised after the record is saved.
onAfterValidate() (opens new window) This event is raised after the validation is performed.
onBeforeCount() (opens new window) This event is raised before an AR finder performs a count call.
onBeforeDelete() (opens new window) This event is raised before the record is deleted.
onBeforeFind() (opens new window) This event is raised before an AR finder performs a find call.
onBeforeSave() (opens new window) This event is raised before the record is saved.
onBeforeValidate() (opens new window) This event is raised before the validation is performed.
onUnsafeAttribute() (opens new window) This method is invoked when an unsafe attribute is being massively assigned.
populateRecord() (opens new window) Creates an active record with the given attributes.
populateRecords() (opens new window) Creates a list of active records based on the input data.
prepAttributesForSave() Prepares the model's attribute values to be saved to the database.
prepAttributesForUse() Return the attribute values to the formats we want to work with in the code.
primaryKey() Returns the table's primary key.
raiseEvent() (opens new window) Raises an event.
refresh() (opens new window) Repopulates this active record with the latest data.
refreshMetaData() (opens new window) Refreshes the meta data for this AR class.
relations() Declares the related models.
resetScope() (opens new window) Resets all scopes and criterias applied.
rules() Returns this model's validation rules.
save() (opens new window) Saves the current record.
saveAttributes() (opens new window) Saves a selected list of attributes.
saveCounters() (opens new window) Saves one or several counter columns for the current AR object.
scopes()
search() Adds search criteria based on this model's attributes.
setAttribute() Sets the named attribute value. You may also use $this->AttributeName to set the attribute value.
setAttributes() (opens new window) Sets the attribute values in a massive way.
setDbCriteria() (opens new window) Sets the query criteria for the current model.
setIsNewRecord() (opens new window) Sets if the record is new.
setOldPrimaryKey() (opens new window) Sets the old primary key value.
setPrimaryKey() (opens new window) Sets the primary key value.
setScenario() (opens new window) Sets the scenario for the model.
setTableAlias() (opens new window) Sets the table alias to be used in queries.
tableName() Returns the name of the associated database table.
together() (opens new window) Sets {@link CDbCriteria::together} property to be true.
unsetAttributes() (opens new window) Sets the attributes to be null.
update() (opens new window) Updates the row represented by this active record.
updateAll() (opens new window) Updates records with the specified condition.
updateByPk() (opens new window) Updates records with the specified primary key(s).
updateCounters() (opens new window) Updates one or several counter columns.
validate() (opens new window) Performs the validation.
with() (opens new window) Specifies which related objects should be eagerly loaded.

# defineRelations()

Defines this model's relations to other models.

BaseRecord::defineRelations()

View source (opens new window)

Returns

array (opens new window)

Signature

public array defineRelations ( )

# getTableName()

Returns the name of the associated database table.

BaseRecord::getTableName()

View source (opens new window)

Returns

string (opens new window)

Signature

public string getTableName ( )

# Protected Methods

Method Description
afterConstruct() (opens new window) This method is invoked after a model instance is created by new operator.
afterDelete() (opens new window) This method is invoked after deleting a record.
afterFind() (opens new window) This method is invoked after each record is instantiated by a find method.
afterSave() (opens new window) This method is invoked after saving a record successfully.
afterValidate() (opens new window) This method is invoked after validation ends.
beforeCount() (opens new window) This method is invoked before an AR finder executes a count call.
beforeDelete() (opens new window) This method is invoked before deleting a record.
beforeFind() (opens new window) This method is invoked before an AR finder executes a find call.
beforeSave() (opens new window) This method is invoked before saving a record (after validation, if any).
beforeValidate() (opens new window) This method is invoked before validation starts.
defineAttributes() Defines this model's attributes.
instantiate() (opens new window) Creates an active record instance.
query() (opens new window) Performs the actual DB query and populates the AR objects with the query result.

# defineAttributes()

Defines this model's attributes.

BaseRecord::defineAttributes()

View source (opens new window)

Returns

array (opens new window)

Signature

protected array defineAttributes ( )

# Constants

Constant Description
BELONGS_TO
CASCADE
HAS_MANY
HAS_ONE
MANY_MANY
NO_ACTION
RESTRICT
SET_DEFAULT
SET_NULL
STAT