Craft\CategoryRecord » Craft\BaseRecord » CActiveRecord » CModel » CComponent
ArrayAccess, IteratorAggregate

Category record.

See also

View source

Public Properties

$dbCDbConnection – The default database connection for all active record classes.

Protected Properties


Public Methods

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


Defines this model's relations to other models.


View source




public array defineRelations ( )


Returns the name of the associated database table.


View source




public string getTableName ( )

Protected Methods

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