Method | Description | |
---|---|---|
attributes ( ) : array | Returns the list of all attribute names of the record. | |
delete ( ) : integer | boolean | Deletes the record from the database. | |
deleteAll ( array $condition = null ) : integer | Deletes records using the provided conditions. | |
equals ( static $record ) : boolean | Returns a value indicating whether the given active record is the same as the current one. | |
find ( ) : yii\db\ActiveQueryInterface | Creates an ActiveQueryInterface instance for query purpose. | |
findAll ( mixed $condition ) : array | Returns a list of active record models that match the specified primary key value(s) or a set of column values. | |
findOne ( mixed $condition ) : static | Returns a single active record model instance by a primary key or an array of column values. | |
getAttribute ( string $name ) : mixed | Returns the named attribute value. | |
getDb ( ) : mixed | Returns the connection used by this AR class. | |
getIsNewRecord ( ) : boolean | Returns a value indicating whether the current record is new (not saved in the database). | |
getOldPrimaryKey ( boolean $asArray = false ) : mixed | Returns the old primary key value(s). | |
getPrimaryKey ( boolean $asArray = false ) : mixed | Returns the primary key value(s). | |
getRelation ( string $name, boolean $throwException = true ) : yii\db\ActiveQueryInterface | Returns the relation object with the specified name. | |
hasAttribute ( string $name ) : boolean | Returns a value indicating whether the record has an attribute with the specified name. | |
insert ( boolean $runValidation = true, array $attributes = null ) : boolean | Inserts the record into the database using the attribute values of this record. | |
isPrimaryKey ( array $keys ) : boolean | Returns a value indicating whether the given set of attributes represents the primary key for this model | |
link ( string $name, static $model, array $extraColumns = [] ) | Establishes the relationship between two records. | |
populateRelation ( string $name, yii\db\ActiveRecordInterface | array | null $records ) | Populates the named relation with the related records. | |
primaryKey ( ) : string[] | Returns the primary key **name(s)** for this AR class. | |
save ( boolean $runValidation = true, array $attributeNames = null ) : boolean | Saves the current record. | |
setAttribute ( string $name, mixed $value ) | Sets the named attribute value. | |
unlink ( string $name, static $model, boolean $delete = false ) | Destroys the relationship between two records. | |
update ( boolean $runValidation = true, array $attributeNames = null ) : integer | boolean | Saves the changes to this active record into the database. | |
updateAll ( array $attributes, array $condition = null ) : integer | Updates records using the provided attribute values and conditions. |
public attributes ( ) : array | ||
return | array | list of attribute names. |
public static deleteAll ( array $condition = null ) : integer | ||
$condition | array | the condition that matches the records that should get deleted. Please refer to [[QueryInterface::where()]] on how to specify this parameter. An empty condition will match all records. |
return | integer | the number of rows deleted |
public static find ( ) : yii\db\ActiveQueryInterface | ||
return | yii\db\ActiveQueryInterface | the newly created [[ActiveQueryInterface]] instance. |
public getAttribute ( string $name ) : mixed | ||
$name | string | the attribute name |
return | mixed | the attribute value. `null` if the attribute is not set or does not exist. |
public getIsNewRecord ( ) : boolean | ||
return | boolean | whether the record is new and should be inserted when calling [[save()]]. |
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. |
return | 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`). |
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 attribute names as keys and attribute values as values. Note that for composite primary keys, an array will always be returned regardless of this parameter value. |
return | mixed | the primary key value. An array (attribute name => attribute 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`). |
public getRelation ( string $name, boolean $throwException = true ) : yii\db\ActiveQueryInterface | ||
$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. |
return | yii\db\ActiveQueryInterface | the relational query object |
public hasAttribute ( string $name ) : boolean | ||
$name | string | the name of the attribute |
return | boolean | whether the record has an attribute with the specified name. |
public insert ( boolean $runValidation = true, array $attributes = null ) : boolean | ||
$runValidation | boolean | whether to perform validation (calling [[\yii\base\Model::validate()|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`. |
$attributes | array | list of attributes that need to be saved. Defaults to `null`, meaning all attributes that are loaded from DB will be saved. |
return | boolean | whether the attributes are valid and the record is inserted successfully. |
public static isPrimaryKey ( array $keys ) : boolean | ||
$keys | array | the set of attributes to check |
return | boolean | whether the given set of attributes represents the primary key for this model |
public link ( string $name, static $model, array $extraColumns = [] ) | ||
$name | string | the case sensitive name of the relationship, e.g. `orders` for a relation defined via `getOrders()` method. |
$model | static | the record to be linked with the current one. |
$extraColumns | array | additional column values to be saved into the junction table. This parameter is only meaningful for a relationship involving a junction table (i.e., a relation set with [[ActiveQueryInterface::via()]]). |
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. |
public static primaryKey ( ) : string[] | ||
return | string[] | the primary key name(s) for this AR class. |
public save ( boolean $runValidation = true, array $attributeNames = null ) : boolean | ||
$runValidation | boolean | whether to perform validation (calling [[\yii\base\Model::validate()|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. |
return | boolean | whether the saving succeeded (i.e. no validation errors occurred). |
public setAttribute ( string $name, mixed $value ) | ||
$name | string | the attribute name. |
$value | mixed | the attribute value. |
public unlink ( string $name, static $model, boolean $delete = false ) | ||
$name | string | the case sensitive name of the relationship, e.g. `orders` for a relation defined via `getOrders()` method. |
$model | static | the model to be unlinked from the current one. |
$delete | boolean | whether to delete the model that contains the foreign key. If false, the model's foreign key will be set `null` and saved. If true, the model containing the foreign key will be deleted. |
public update ( boolean $runValidation = true, array $attributeNames = null ) : integer | boolean | ||
$runValidation | boolean | whether to perform validation (calling [[\yii\base\Model::validate()|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 attributes that need to be saved. Defaults to `null`, meaning all attributes that are loaded from DB will be saved. |
return | integer | boolean | the number of rows affected, or `false` if validation fails or updating process is stopped for other reasons. Note that it is possible that the number of rows affected is 0, even though the update execution is successful. |
public static updateAll ( array $attributes, array $condition = null ) : integer | ||
$attributes | array | attribute values (name-value pairs) to be saved for the record. Unlike [[update()]] these are not going to be validated. |
$condition | array | the condition that matches the records that should get updated. Please refer to [[QueryInterface::where()]] on how to specify this parameter. An empty condition will match all records. |
return | integer | the number of rows updated |