PHP 클래스 yii\db\BaseActiveRecord

See ActiveRecord for a concrete implementation.
부터: 2.0
저자: Qiang Xue ([email protected])
저자: Carsten Brandt ([email protected])
상속: extends yii\base\Model, implements yii\db\ActiveRecordInterface
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 메소드들

메소드 설명
__get ( string $name ) : mixed PHP getter magic method.
__isset ( string $name ) : boolean Checks if a property value is null.
__set ( string $name, mixed $value ) PHP setter magic method.
__unset ( string $name ) Sets a component property to be null.
afterDelete ( ) This method is invoked after deleting a record.
afterFind ( ) This method is called when the AR object is created and populated with the query result.
afterRefresh ( ) This method is called when the AR object is refreshed.
afterSave ( boolean $insert, array $changedAttributes ) This method is called at the end of inserting or updating a record.
beforeDelete ( ) : boolean This method is invoked before deleting a record.
beforeSave ( boolean $insert ) : boolean This method is called at the beginning of inserting or updating a record.
canGetProperty ( $name, $checkVars = true, $checkBehaviors = true )
canSetProperty ( $name, $checkVars = true, $checkBehaviors = true )
delete ( ) : integer | false Deletes the table row corresponding to this active record.
deleteAll ( string | array $condition = '', array $params = [] ) : integer Deletes rows in the table using the provided conditions.
equals ( yii\db\ActiveRecordInterface $record ) : boolean Returns a value indicating whether the given active record is the same as the current one.
extraFields ( )
fields ( )
findAll ( $condition ) : static[]
findOne ( $condition ) : static
getAttribute ( string $name ) : mixed Returns the named attribute value.
getAttributeHint ( string $attribute ) : string Returns the text hint for the specified attribute.
getAttributeLabel ( string $attribute ) : string Returns the text label for the specified attribute.
getDirtyAttributes ( string[] | null $names = null ) : array Returns the attribute values that have been modified since they are loaded or saved most recently.
getIsNewRecord ( ) : boolean Returns a value indicating whether the current record is new.
getOldAttribute ( string $name ) : mixed Returns the old value of the named attribute.
getOldAttributes ( ) : array Returns the old attribute values.
getOldPrimaryKey ( boolean $asArray = false ) : mixed Returns the old primary key value(s).
getPrimaryKey ( boolean $asArray = false ) : mixed Returns the primary key value(s).
getRelatedRecords ( ) : array Returns all populated related records.
getRelation ( string $name, boolean $throwException = true ) : yii\db\ActiveQueryInterface | ActiveQuery Returns the relation object with the specified name.
hasAttribute ( string $name ) : boolean Returns a value indicating whether the model has an attribute with the specified name.
hasMany ( string $class, array $link ) : yii\db\ActiveQueryInterface Declares a has-many relation.
hasOne ( string $class, array $link ) : yii\db\ActiveQueryInterface Declares a has-one relation.
init ( ) Initializes the object.
instantiate ( array $row ) : static Creates an active record instance.
isAttributeChanged ( string $name, boolean $identical = true ) : boolean Returns a value indicating whether the named attribute has been changed.
isPrimaryKey ( array $keys ) : boolean Returns a value indicating whether the given set of attributes represents the primary key for this model
isRelationPopulated ( string $name ) : boolean Check whether the named relation has been populated with records.
link ( string $name, yii\db\ActiveRecordInterface $model, array $extraColumns = [] ) Establishes the relationship between two models.
markAttributeDirty ( string $name ) Marks an attribute dirty.
offsetExists ( mixed $offset ) : boolean Returns whether there is an element at the specified offset.
offsetUnset ( mixed $offset ) Sets the element value at the specified offset to null.
optimisticLock ( ) : string Returns the name of the column that stores the lock version for implementing optimistic locking.
populateRecord ( BaseActiveRecord $record, array $row ) Populates an active record object using a row of data from the database/storage.
populateRelation ( string $name, yii\db\ActiveRecordInterface | array | null $records ) Populates the named relation with the related records.
refresh ( ) : boolean Repopulates this active record with the latest data.
save ( boolean $runValidation = true, array $attributeNames = null ) : boolean Saves the current record.
setAttribute ( string $name, mixed $value ) Sets the named attribute value.
setIsNewRecord ( boolean $value ) Sets the value indicating whether the record is new.
setOldAttribute ( string $name, mixed $value ) Sets the old value of the named attribute.
setOldAttributes ( array | null $values ) Sets the old attribute values.
unlink ( string $name, yii\db\ActiveRecordInterface $model, boolean $delete = false ) Destroys the relationship between two models.
unlinkAll ( string $name, boolean $delete = false ) Destroys the relationship in current model.
update ( boolean $runValidation = true, array $attributeNames = null ) : integer | false Saves the changes to this active record into the associated database table.
updateAll ( array $attributes, string | array $condition = '' ) : integer Updates the whole table using the provided attribute values and conditions.
updateAllCounters ( array $counters, string | array $condition = '' ) : integer Updates the whole table using the provided counter changes and conditions.
updateAttributes ( array $attributes ) : integer Updates the specified attributes.
updateCounters ( array $counters ) : boolean Updates one or several counter columns for the current AR object.

보호된 메소드들

메소드 설명
findByCondition ( mixed $condition ) : yii\db\ActiveQueryInterface Finds ActiveRecord instance(s) by the given condition.
updateInternal ( array $attributes = null ) : integer | false

비공개 메소드들

메소드 설명
bindModels ( array $link, yii\db\ActiveRecordInterface $foreignModel, yii\db\ActiveRecordInterface $primaryModel )

메소드 상세

__get() 공개 메소드

This method is overridden so that attributes and related objects can be accessed like properties.
또한 보기: getAttribute()
public __get ( string $name ) : mixed
$name string property name
리턴 mixed property value

__isset() 공개 메소드

This method overrides the parent implementation by checking if the named attribute is null or not.
public __isset ( string $name ) : boolean
$name string the property name or the event name
리턴 boolean whether the property value is null

__set() 공개 메소드

This method is overridden so that AR attributes can be accessed like properties.
public __set ( string $name, mixed $value )
$name string property name
$value mixed property value

__unset() 공개 메소드

This method overrides the parent implementation by clearing the specified attribute value.
public __unset ( string $name )
$name string the property name or the event name

afterDelete() 공개 메소드

The default implementation raises the [[EVENT_AFTER_DELETE]] event. You may override this method to do postprocessing after the record is deleted. Make sure you call the parent implementation so that the event is raised properly.
public afterDelete ( )

afterFind() 공개 메소드

The default implementation will trigger an [[EVENT_AFTER_FIND]] event. When overriding this method, make sure you call the parent implementation to ensure the event is triggered.
public afterFind ( )

afterRefresh() 공개 메소드

The default implementation will trigger an [[EVENT_AFTER_REFRESH]] event. When overriding this method, make sure you call the parent implementation to ensure the event is triggered.
부터: 2.0.8
public afterRefresh ( )

afterSave() 공개 메소드

The default implementation will trigger an [[EVENT_AFTER_INSERT]] event when $insert is true, or an [[EVENT_AFTER_UPDATE]] event if $insert is false. The event class used is [[AfterSaveEvent]]. When overriding this method, make sure you call the parent implementation so that the event is triggered.
public afterSave ( boolean $insert, array $changedAttributes )
$insert boolean whether this method called while inserting a record. If `false`, it means the method is called while updating a record.
$changedAttributes array The old values of attributes that had changed and were saved. You can use this parameter to take action based on the changes made for example send an email when the password had changed or implement audit trail that tracks all the changes. `$changedAttributes` gives you the old attribute values while the active record (`$this`) has already the new, updated values. Note that no automatic type conversion performed by default. You may use [[\yii\behaviors\AttributeTypecastBehavior]] to facilitate attribute typecasting. See http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#attributes-typecasting.

beforeDelete() 공개 메소드

The default implementation raises the [[EVENT_BEFORE_DELETE]] event. When overriding this method, make sure you call the parent implementation like the following: php public function beforeDelete() { if (parent::beforeDelete()) { ...custom code here... return true; } else { return false; } }
public beforeDelete ( ) : boolean
리턴 boolean whether the record should be deleted. Defaults to `true`.

beforeSave() 공개 메소드

The default implementation will trigger an [[EVENT_BEFORE_INSERT]] event when $insert is true, or an [[EVENT_BEFORE_UPDATE]] event if $insert is false. When overriding this method, make sure you call the parent implementation like the following: php public function beforeSave($insert) { if (parent::beforeSave($insert)) { ...custom code here... return true; } else { return false; } }
public beforeSave ( boolean $insert ) : boolean
$insert boolean whether this method called while inserting a record. If `false`, it means the method is called while updating a record.
리턴 boolean whether the insertion or updating should continue. If `false`, the insertion or updating will be cancelled.

canGetProperty() 공개 메소드

public canGetProperty ( $name, $checkVars = true, $checkBehaviors = true )

canSetProperty() 공개 메소드

public canSetProperty ( $name, $checkVars = true, $checkBehaviors = true )

delete() 공개 메소드

This method performs the following steps in order: 1. call BaseActiveRecord::beforeDelete. If the method returns false, it will skip the rest of the steps; 2. delete the record from the database; 3. call BaseActiveRecord::afterDelete. In the above step 1 and 3, events named [[EVENT_BEFORE_DELETE]] and [[EVENT_AFTER_DELETE]] will be raised by the corresponding methods.
public delete ( ) : integer | false
리턴 integer | false the number of rows deleted, or `false` if the deletion is unsuccessful for some reason. Note that it is possible the number of rows deleted is 0, even though the deletion execution is successful.

deleteAll() 공개 정적인 메소드

WARNING: If you do not specify any condition, this method will delete ALL rows in the table. For example, to delete all customers whose status is 3: php Customer::deleteAll('status = 3');
public static deleteAll ( string | array $condition = '', array $params = [] ) : integer
$condition string | array the conditions that will be put in the WHERE part of the DELETE SQL. Please refer to [[Query::where()]] on how to specify this parameter.
$params array the parameters (name => value) to be bound to the query.
리턴 integer the number of rows deleted

equals() 공개 메소드

The comparison is made by comparing the table names and the primary key values of the two active records. If one of the records [[isNewRecord|is new]] they are also considered not equal.
public equals ( yii\db\ActiveRecordInterface $record ) : boolean
$record yii\db\ActiveRecordInterface record to compare to
리턴 boolean whether the two active records refer to the same row in the same database table.

extraFields() 공개 메소드

public extraFields ( )

fields() 공개 메소드

public fields ( )

findAll() 공개 정적인 메소드

public static findAll ( $condition ) : static[]
리턴 static[] an array of ActiveRecord instances, or an empty array if nothing matches.

findByCondition() 보호된 정적인 메소드

This method is internally called by BaseActiveRecord::findOne and BaseActiveRecord::findAll.
protected static findByCondition ( mixed $condition ) : yii\db\ActiveQueryInterface
$condition mixed please refer to [[findOne()]] for the explanation of this parameter
리턴 yii\db\ActiveQueryInterface the newly created [[ActiveQueryInterface|ActiveQuery]] instance.

findOne() 공개 정적인 메소드

public static findOne ( $condition ) : static
리턴 static ActiveRecord instance matching the condition, or `null` if nothing matches.

getAttribute() 공개 메소드

If this record is the result of a query and the attribute is not loaded, null will be returned.
또한 보기: hasAttribute()
public getAttribute ( string $name ) : mixed
$name string the attribute name
리턴 mixed the attribute value. `null` if the attribute is not set or does not exist.

getAttributeHint() 공개 메소드

If the attribute looks like relatedModel.attribute, then the attribute will be received from the related model.
또한 보기: attributeHints()
부터: 2.0.4
public getAttributeHint ( string $attribute ) : string
$attribute string the attribute name
리턴 string the attribute hint

getAttributeLabel() 공개 메소드

If the attribute looks like relatedModel.attribute, then the attribute will be received from the related model.
또한 보기: generateAttributeLabel()
또한 보기: attributeLabels()
public getAttributeLabel ( string $attribute ) : string
$attribute string the attribute name
리턴 string the attribute label

getDirtyAttributes() 공개 메소드

The comparison of new and old values is made for identical values using ===.
public getDirtyAttributes ( string[] | null $names = null ) : array
$names string[] | null the names of the attributes whose values may be returned if they are changed recently. If null, [[attributes()]] will be used.
리턴 array the changed attribute values (name-value pairs)

getIsNewRecord() 공개 메소드

Returns a value indicating whether the current record is new.
public getIsNewRecord ( ) : boolean
리턴 boolean whether the record is new and should be inserted when calling [[save()]].

getOldAttribute() 공개 메소드

If this record is the result of a query and the attribute is not loaded, null will be returned.
또한 보기: hasAttribute()
public getOldAttribute ( string $name ) : mixed
$name string the attribute name
리턴 mixed the old attribute value. `null` if the attribute is not loaded before or does not exist.

getOldAttributes() 공개 메소드

Returns the old attribute values.
public getOldAttributes ( ) : array
리턴 array the old attribute values (name-value pairs)

getOldPrimaryKey() 공개 메소드

This refers to the primary key value that is populated into the record after executing a find method (e.g. find(), findOne()). The value remains unchanged even if the primary key attribute is manually assigned with a different value.
public getOldPrimaryKey ( boolean $asArray = false ) : mixed
$asArray boolean whether to return the primary key value as an array. If `true`, the return value will be an array with column name as key and column value as value. If this is `false` (default), a scalar value will be returned for non-composite primary key.
리턴 mixed the old primary key value. An array (column name => column value) is returned if the primary key is composite or `$asArray` is `true`. A string is returned otherwise (null will be returned if the key value is null).

getPrimaryKey() 공개 메소드

Returns the primary key value(s).
public getPrimaryKey ( boolean $asArray = false ) : mixed
$asArray boolean whether to return the primary key value as an array. If `true`, the return value will be an array with column names as keys and column values as values. Note that for composite primary keys, an array will always be returned regardless of this parameter value.
리턴 mixed the primary key value. An array (column name => column value) is returned if the primary key is composite or `$asArray` is `true`. A string is returned otherwise (null will be returned if the key value is null).

getRelatedRecords() 공개 메소드

Returns all populated related records.
또한 보기: getRelation()
public getRelatedRecords ( ) : array
리턴 array an array of related records indexed by relation names.

getRelation() 공개 메소드

A relation is defined by a getter method which returns an ActiveQueryInterface object. It can be declared in either the Active Record class itself or one of its behaviors.
public getRelation ( string $name, boolean $throwException = true ) : yii\db\ActiveQueryInterface | ActiveQuery
$name string the relation name, e.g. `orders` for a relation defined via `getOrders()` method (case-sensitive).
$throwException boolean whether to throw exception if the relation does not exist.
리턴 yii\db\ActiveQueryInterface | ActiveQuery the relational query object. If the relation does not exist and `$throwException` is `false`, `null` will be returned.

hasAttribute() 공개 메소드

Returns a value indicating whether the model has an attribute with the specified name.
public hasAttribute ( string $name ) : boolean
$name string the name of the attribute
리턴 boolean whether the model has an attribute with the specified name.

hasMany() 공개 메소드

The declaration is returned in terms of a relational ActiveQuery instance through which the related record can be queried and retrieved back. A has-many relation means that there are multiple related records matching the criteria set by this relation, e.g., a customer has many orders. For example, to declare the orders relation for Customer class, we can write the following code in the Customer class: php public function getOrders() { return $this->hasMany(Order::className(), ['customer_id' => 'id']); } Note that in the above, the 'customer_id' key in the $link parameter refers to an attribute name in the related class Order, while the 'id' value refers to an attribute name in the current AR class. Call methods declared in ActiveQuery to further customize the relation.
public hasMany ( string $class, array $link ) : yii\db\ActiveQueryInterface
$class string the class name of the related record
$link array the primary-foreign key constraint. The keys of the array refer to the attributes of the record associated with the `$class` model, while the values of the array refer to the corresponding attributes in **this** AR class.
리턴 yii\db\ActiveQueryInterface the relational query object.

hasOne() 공개 메소드

The declaration is returned in terms of a relational ActiveQuery instance through which the related record can be queried and retrieved back. A has-one relation means that there is at most one related record matching the criteria set by this relation, e.g., a customer has one country. For example, to declare the country relation for Customer class, we can write the following code in the Customer class: php public function getCountry() { return $this->hasOne(Country::className(), ['id' => 'country_id']); } Note that in the above, the 'id' key in the $link parameter refers to an attribute name in the related class Country, while the 'country_id' value refers to an attribute name in the current AR class. Call methods declared in ActiveQuery to further customize the relation.
public hasOne ( string $class, array $link ) : yii\db\ActiveQueryInterface
$class string the class name of the related record
$link array the primary-foreign key constraint. The keys of the array refer to the attributes of the record associated with the `$class` model, while the values of the array refer to the corresponding attributes in **this** AR class.
리턴 yii\db\ActiveQueryInterface the relational query object.

init() 공개 메소드

This method is called at the end of the constructor. The default implementation will trigger an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end to ensure triggering of the event.
public init ( )

instantiate() 공개 정적인 메소드

This method is called together with BaseActiveRecord::populateRecord by ActiveQuery. It is not meant to be used for creating new records directly. You may override this method if the instance being created depends on the row data to be populated into the record. For example, by creating a record based on the value of a column, you may implement the so-called single-table inheritance mapping.
public static instantiate ( array $row ) : static
$row array row data to be populated into the record.
리턴 static the newly created active record

isAttributeChanged() 공개 메소드

Returns a value indicating whether the named attribute has been changed.
public isAttributeChanged ( string $name, boolean $identical = true ) : boolean
$name string the name of the attribute.
$identical boolean whether the comparison of new and old value is made for identical values using `===`, defaults to `true`. Otherwise `==` is used for comparison. This parameter is available since version 2.0.4.
리턴 boolean whether the attribute has been changed

isPrimaryKey() 공개 정적인 메소드

Returns a value indicating whether the given set of attributes represents the primary key for this model
public static isPrimaryKey ( array $keys ) : boolean
$keys array the set of attributes to check
리턴 boolean whether the given set of attributes represents the primary key for this model

isRelationPopulated() 공개 메소드

Check whether the named relation has been populated with records.
또한 보기: getRelation()
public isRelationPopulated ( string $name ) : boolean
$name string the relation name, e.g. `orders` for a relation defined via `getOrders()` method (case-sensitive).
리턴 boolean whether relation has been populated with records.

markAttributeDirty() 공개 메소드

This method may be called to force updating a record when calling BaseActiveRecord::update, even if there is no change being made to the record.
public markAttributeDirty ( string $name )
$name string the attribute name

offsetExists() 공개 메소드

This method is required by the interface [[\ArrayAccess]].
public offsetExists ( mixed $offset ) : boolean
$offset mixed the offset to check on
리턴 boolean whether there is an element at the specified offset.

offsetUnset() 공개 메소드

This method is required by the SPL interface [[\ArrayAccess]]. It is implicitly called when you use something like unset($model[$offset]).
public offsetUnset ( mixed $offset )
$offset mixed the offset to unset element

optimisticLock() 공개 메소드

Optimistic locking allows multiple users to access the same record for edits and avoids potential conflicts. In case when a user attempts to save the record upon some staled data (because another user has modified the data), a [[StaleObjectException]] exception will be thrown, and the update or deletion is skipped. Optimistic locking is only supported by BaseActiveRecord::update and BaseActiveRecord::delete. To use Optimistic locking: 1. Create a column to store the version number of each row. The column type should be BIGINT DEFAULT 0. Override this method to return the name of this column. 2. Add a required validation rule for the version column to ensure the version value is submitted. 3. In the Web form that collects the user input, add a hidden field that stores the lock version of the recording being updated. 4. In the controller action that does the data updating, try to catch the [[StaleObjectException]] and implement necessary business logic (e.g. merging the changes, prompting stated data) to resolve the conflict.
public optimisticLock ( ) : string
리턴 string the column name that stores the lock version of a table row. If `null` is returned (default implemented), optimistic locking will not be supported.

populateRecord() 공개 정적인 메소드

This is an internal method meant to be called to create active record objects after fetching data from the database. It is mainly used by ActiveQuery to populate the query results into active records. When calling this method manually you should call BaseActiveRecord::afterFind on the created record to trigger the [[EVENT_AFTER_FIND|afterFind Event]].
public static populateRecord ( BaseActiveRecord $record, array $row )
$record BaseActiveRecord the record to be populated. In most cases this will be an instance created by [[instantiate()]] beforehand.
$row array attribute values (name => value)

populateRelation() 공개 메소드

Note that this method does not check if the relation exists or not.
또한 보기: getRelation()
public populateRelation ( string $name, yii\db\ActiveRecordInterface | array | null $records )
$name string the relation name, e.g. `orders` for a relation defined via `getOrders()` method (case-sensitive).
$records yii\db\ActiveRecordInterface | array | null the related records to be populated into the relation.

refresh() 공개 메소드

If the refresh is successful, an [[EVENT_AFTER_REFRESH]] event will be triggered. This event is available since version 2.0.8.
public refresh ( ) : boolean
리턴 boolean whether the row still exists in the database. If `true`, the latest data will be populated to this active record. Otherwise, this record will remain unchanged.

save() 공개 메소드

This method will call [[insert()]] when [[isNewRecord]] is true, or BaseActiveRecord::update when [[isNewRecord]] is false. For example, to save a customer record: php $customer = new Customer; // or $customer = Customer::findOne($id); $customer->name = $name; $customer->email = $email; $customer->save();
public save ( boolean $runValidation = true, array $attributeNames = null ) : boolean
$runValidation boolean whether to perform validation (calling [[validate()]]) before saving the record. Defaults to `true`. If the validation fails, the record will not be saved to the database and this method will return `false`.
$attributeNames array list of attribute names that need to be saved. Defaults to null, meaning all attributes that are loaded from DB will be saved.
리턴 boolean whether the saving succeeded (i.e. no validation errors occurred).

setAttribute() 공개 메소드

Sets the named attribute value.
또한 보기: hasAttribute()
public setAttribute ( string $name, mixed $value )
$name string the attribute name
$value mixed the attribute value.

setIsNewRecord() 공개 메소드

Sets the value indicating whether the record is new.
또한 보기: getIsNewRecord()
public setIsNewRecord ( boolean $value )
$value boolean whether the record is new and should be inserted when calling [[save()]].

setOldAttribute() 공개 메소드

Sets the old value of the named attribute.
또한 보기: hasAttribute()
public setOldAttribute ( string $name, mixed $value )
$name string the attribute name
$value mixed the old attribute value.

setOldAttributes() 공개 메소드

All existing old attribute values will be discarded.
public setOldAttributes ( array | null $values )
$values array | null old attribute values to be set. If set to `null` this record is considered to be [[isNewRecord|new]].

unlinkAll() 공개 메소드

The model with the foreign key of the relationship will be deleted if $delete is true. Otherwise, the foreign key will be set null and the model will be saved without validation. Note that to destroy the relationship without removing records make sure your keys can be set to null
public unlinkAll ( string $name, boolean $delete = false )
$name string the case sensitive name of the relationship, e.g. `orders` for a relation defined via `getOrders()` method.
$delete boolean whether to delete the model that contains the foreign key.

update() 공개 메소드

This method performs the following steps in order: 1. call [[beforeValidate()]] when $runValidation is true. If [[beforeValidate()]] returns false, the rest of the steps will be skipped; 2. call [[afterValidate()]] when $runValidation is true. If validation failed, the rest of the steps will be skipped; 3. call BaseActiveRecord::beforeSave. If BaseActiveRecord::beforeSave returns false, the rest of the steps will be skipped; 4. save the record into database. If this fails, it will skip the rest of the steps; 5. call BaseActiveRecord::afterSave; In the above step 1, 2, 3 and 5, events [[EVENT_BEFORE_VALIDATE]], [[EVENT_AFTER_VALIDATE]], [[EVENT_BEFORE_UPDATE]], and [[EVENT_AFTER_UPDATE]] will be raised by the corresponding methods. Only the [[dirtyAttributes|changed attribute values]] will be saved into database. For example, to update a customer record: php $customer = Customer::findOne($id); $customer->name = $name; $customer->email = $email; $customer->update(); Note that it is possible the update does not affect any row in the table. In this case, this method will return 0. For this reason, you should use the following code to check if update() is successful or not: php if ($customer->update() !== false) { update successful } else { update failed }
public update ( boolean $runValidation = true, array $attributeNames = null ) : integer | false
$runValidation boolean whether to perform validation (calling [[validate()]]) before saving the record. Defaults to `true`. If the validation fails, the record will not be saved to the database and this method will return `false`.
$attributeNames array list of attribute names that need to be saved. Defaults to null, meaning all attributes that are loaded from DB will be saved.
리턴 integer | false the number of rows affected, or `false` if validation fails or [[beforeSave()]] stops the updating process.

updateAll() 공개 정적인 메소드

For example, to change the status to be 1 for all customers whose status is 2: php Customer::updateAll(['status' => 1], 'status = 2');
public static updateAll ( array $attributes, string | array $condition = '' ) : integer
$attributes array attribute values (name-value pairs) to be saved into the table
$condition string | array the conditions that will be put in the WHERE part of the UPDATE SQL. Please refer to [[Query::where()]] on how to specify this parameter.
리턴 integer the number of rows updated

updateAllCounters() 공개 정적인 메소드

For example, to increment all customers' age by 1, php Customer::updateAllCounters(['age' => 1]);
public static updateAllCounters ( array $counters, string | array $condition = '' ) : integer
$counters array the counters to be updated (attribute name => increment value). Use negative values if you want to decrement the counters.
$condition string | array the conditions that will be put in the WHERE part of the UPDATE SQL. Please refer to [[Query::where()]] on how to specify this parameter.
리턴 integer the number of rows updated

updateAttributes() 공개 메소드

This method is a shortcut to BaseActiveRecord::update when data validation is not needed and only a small set attributes need to be updated. You may specify the attributes to be updated as name list or name-value pairs. If the latter, the corresponding attribute values will be modified accordingly. The method will then save the specified attributes into database. Note that this method will **not** perform data validation and will **not** trigger events.
public updateAttributes ( array $attributes ) : integer
$attributes array the attributes (names or name-value pairs) to be updated
리턴 integer the number of rows affected.

updateCounters() 공개 메소드

Note that this method differs from BaseActiveRecord::updateAllCounters in that it only saves counters for the current AR object. An example usage is as follows: php $post = Post::findOne($id); $post->updateCounters(['view_count' => 1]);
또한 보기: updateAllCounters()
public updateCounters ( array $counters ) : boolean
$counters array the counters to be updated (attribute name => increment value) Use negative values if you want to decrement the counters.
리턴 boolean whether the saving is successful

updateInternal() 보호된 메소드

또한 보기: update()
protected updateInternal ( array $attributes = null ) : integer | false
$attributes array attributes to update
리턴 integer | false the number of rows affected, or false if [[beforeSave()]] stops the updating process.