|
|
@ -53,7 +53,7 @@ $post->save(); |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0 |
|
|
|
* @since 2.0 |
|
|
|
* |
|
|
|
* |
|
|
|
* @property array $attributes |
|
|
|
* @property array $attributes |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -111,7 +111,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @param integer $queryCount number of SQL queries that need to be cached after calling this method. Defaults to 1, |
|
|
|
* @param integer $queryCount number of SQL queries that need to be cached after calling this method. Defaults to 1, |
|
|
|
* meaning that the next SQL query will be cached. |
|
|
|
* meaning that the next SQL query will be cached. |
|
|
|
* @return ActiveRecord the active record instance itself. |
|
|
|
* @return ActiveRecord the active record instance itself. |
|
|
|
* @since 1.1.7 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function cache($duration, $dependency = null, $queryCount = 1) |
|
|
|
public function cache($duration, $dependency = null, $queryCount = 1) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -174,7 +173,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* if the named attribute is null or not. |
|
|
|
* if the named attribute is null or not. |
|
|
|
* @param string $name the property name or the event name |
|
|
|
* @param string $name the property name or the event name |
|
|
|
* @return boolean whether the property value is null |
|
|
|
* @return boolean whether the property value is null |
|
|
|
* @since 1.0.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function __isset($name) |
|
|
|
public function __isset($name) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -195,7 +193,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This method overrides the parent implementation by clearing |
|
|
|
* This method overrides the parent implementation by clearing |
|
|
|
* the specified attribute value. |
|
|
|
* the specified attribute value. |
|
|
|
* @param string $name the property name or the event name |
|
|
|
* @param string $name the property name or the event name |
|
|
|
* @since 1.0.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function __unset($name) |
|
|
|
public function __unset($name) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -214,7 +211,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @param string $name the method name |
|
|
|
* @param string $name the method name |
|
|
|
* @param array $parameters method parameters |
|
|
|
* @param array $parameters method parameters |
|
|
|
* @return mixed the method return value |
|
|
|
* @return mixed the method return value |
|
|
|
* @since 1.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function __call($name, $parameters) |
|
|
|
public function __call($name, $parameters) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -249,7 +245,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This parameter has been available since version 1.0.5. |
|
|
|
* This parameter has been available since version 1.0.5. |
|
|
|
* @return mixed the related object(s). |
|
|
|
* @return mixed the related object(s). |
|
|
|
* @throws CDbException if the relation is not specified in {@link relations}. |
|
|
|
* @throws CDbException if the relation is not specified in {@link relations}. |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getRelated($name, $refresh = false, $params = array()) |
|
|
|
public function getRelated($name, $refresh = false, $params = array()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -307,7 +302,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* Returns a value indicating whether the named related object(s) has been loaded. |
|
|
|
* Returns a value indicating whether the named related object(s) has been loaded. |
|
|
|
* @param string $name the relation name |
|
|
|
* @param string $name the relation name |
|
|
|
* @return boolean a value indicating whether the named related object(s) has been loaded. |
|
|
|
* @return boolean a value indicating whether the named related object(s) has been loaded. |
|
|
|
* @since 1.0.3 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function hasRelated($name) |
|
|
|
public function hasRelated($name) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -320,7 +314,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @return CDbCriteria the query criteria that is associated with this model. |
|
|
|
* @return CDbCriteria the query criteria that is associated with this model. |
|
|
|
* This criteria is mainly used by {@link scopes named scope} feature to accumulate |
|
|
|
* This criteria is mainly used by {@link scopes named scope} feature to accumulate |
|
|
|
* different criteria specifications. |
|
|
|
* different criteria specifications. |
|
|
|
* @since 1.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getDbCriteria($createIfNull = true) |
|
|
|
public function getDbCriteria($createIfNull = true) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -335,7 +328,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the query criteria for the current model. |
|
|
|
* Sets the query criteria for the current model. |
|
|
|
* @param CDbCriteria $criteria the query criteria |
|
|
|
* @param CDbCriteria $criteria the query criteria |
|
|
|
* @since 1.1.3 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function setDbCriteria($criteria) |
|
|
|
public function setDbCriteria($criteria) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -349,7 +341,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* if the model needs to be queried with some default criteria (e.g. only active records should be returned). |
|
|
|
* if the model needs to be queried with some default criteria (e.g. only active records should be returned). |
|
|
|
* @return array the query criteria. This will be used as the parameter to the constructor |
|
|
|
* @return array the query criteria. This will be used as the parameter to the constructor |
|
|
|
* of {@link CDbCriteria}. |
|
|
|
* of {@link CDbCriteria}. |
|
|
|
* @since 1.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function defaultScope() |
|
|
|
public function defaultScope() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -360,7 +351,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* Resets all scopes and criterias applied including default scope. |
|
|
|
* Resets all scopes and criterias applied including default scope. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return ActiveRecord |
|
|
|
* @return ActiveRecord |
|
|
|
* @since 1.1.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function resetScope() |
|
|
|
public function resetScope() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -415,7 +405,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This is useful if the table schema has been changed and you want to use the latest |
|
|
|
* This is useful if the table schema has been changed and you want to use the latest |
|
|
|
* available table schema. Make sure you have called {@link CDbSchema::refresh} |
|
|
|
* available table schema. Make sure you have called {@link CDbSchema::refresh} |
|
|
|
* before you call this method. Otherwise, old table schema data will still be used. |
|
|
|
* before you call this method. Otherwise, old table schema data will still be used. |
|
|
|
* @since 1.0.8 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function refreshMetaData() |
|
|
|
public function refreshMetaData() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -446,7 +435,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* If the key is a single column, it should return the column name; |
|
|
|
* If the key is a single column, it should return the column name; |
|
|
|
* If the key is a composite one consisting of several columns, it should |
|
|
|
* If the key is a composite one consisting of several columns, it should |
|
|
|
* return the array of the key column names. |
|
|
|
* return the array of the key column names. |
|
|
|
* @since 1.0.4 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function primaryKey() |
|
|
|
public function primaryKey() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -566,7 +554,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @return array the scope definition. The array keys are scope names; the array |
|
|
|
* @return array the scope definition. The array keys are scope names; the array |
|
|
|
* values are the corresponding scope definitions. Each scope definition is represented |
|
|
|
* values are the corresponding scope definitions. Each scope definition is represented |
|
|
|
* as an array whose keys must be properties of {@link CDbCriteria}. |
|
|
|
* as an array whose keys must be properties of {@link CDbCriteria}. |
|
|
|
* @since 1.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function scopes() |
|
|
|
public function scopes() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -577,7 +564,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* Returns the list of all attribute names of the model. |
|
|
|
* Returns the list of all attribute names of the model. |
|
|
|
* This would return all column names of the table associated with this AR class. |
|
|
|
* This would return all column names of the table associated with this AR class. |
|
|
|
* @return array list of attribute names. |
|
|
|
* @return array list of attribute names. |
|
|
|
* @since 1.0.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function attributeNames() |
|
|
|
public function attributeNames() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -593,7 +579,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @param string $attribute the attribute name |
|
|
|
* @param string $attribute the attribute name |
|
|
|
* @return string the attribute label |
|
|
|
* @return string the attribute label |
|
|
|
* @see generateAttributeLabel |
|
|
|
* @see generateAttributeLabel |
|
|
|
* @since 1.1.4 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getAttributeLabel($attribute) |
|
|
|
public function getAttributeLabel($attribute) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -834,7 +819,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This event is raised before the record is saved. |
|
|
|
* This event is raised before the record is saved. |
|
|
|
* By setting {@link CModelEvent::isValid} to be false, the normal {@link save()} process will be stopped. |
|
|
|
* By setting {@link CModelEvent::isValid} to be false, the normal {@link save()} process will be stopped. |
|
|
|
* @param CModelEvent $event the event parameter |
|
|
|
* @param CModelEvent $event the event parameter |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function onBeforeSave($event) |
|
|
|
public function onBeforeSave($event) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -844,7 +828,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
/** |
|
|
|
/** |
|
|
|
* This event is raised after the record is saved. |
|
|
|
* This event is raised after the record is saved. |
|
|
|
* @param CEvent $event the event parameter |
|
|
|
* @param CEvent $event the event parameter |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function onAfterSave($event) |
|
|
|
public function onAfterSave($event) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -855,7 +838,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This event is raised before the record is deleted. |
|
|
|
* This event is raised before the record is deleted. |
|
|
|
* By setting {@link CModelEvent::isValid} to be false, the normal {@link delete()} process will be stopped. |
|
|
|
* By setting {@link CModelEvent::isValid} to be false, the normal {@link delete()} process will be stopped. |
|
|
|
* @param CModelEvent $event the event parameter |
|
|
|
* @param CModelEvent $event the event parameter |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function onBeforeDelete($event) |
|
|
|
public function onBeforeDelete($event) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -865,7 +847,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
/** |
|
|
|
/** |
|
|
|
* This event is raised after the record is deleted. |
|
|
|
* This event is raised after the record is deleted. |
|
|
|
* @param CEvent $event the event parameter |
|
|
|
* @param CEvent $event the event parameter |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function onAfterDelete($event) |
|
|
|
public function onAfterDelete($event) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -880,7 +861,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* You can modify either criteria to customize them based on needs. |
|
|
|
* You can modify either criteria to customize them based on needs. |
|
|
|
* @param CModelEvent $event the event parameter |
|
|
|
* @param CModelEvent $event the event parameter |
|
|
|
* @see beforeFind |
|
|
|
* @see beforeFind |
|
|
|
* @since 1.0.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function onBeforeFind($event) |
|
|
|
public function onBeforeFind($event) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -890,7 +870,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
/** |
|
|
|
/** |
|
|
|
* This event is raised after the record is instantiated by a find method. |
|
|
|
* This event is raised after the record is instantiated by a find method. |
|
|
|
* @param CEvent $event the event parameter |
|
|
|
* @param CEvent $event the event parameter |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function onAfterFind($event) |
|
|
|
public function onAfterFind($event) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -971,8 +950,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* |
|
|
|
* |
|
|
|
* Starting from version 1.1.5, this method may be called with a hidden {@link CDbCriteria} |
|
|
|
* Starting from version 1.1.5, this method may be called with a hidden {@link CDbCriteria} |
|
|
|
* parameter which represents the current query criteria as passed to a find method of AR. |
|
|
|
* parameter which represents the current query criteria as passed to a find method of AR. |
|
|
|
* |
|
|
|
|
|
|
|
* @since 1.0.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function beforeFind() |
|
|
|
protected function beforeFind() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1000,7 +977,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Calls {@link beforeFind}. |
|
|
|
* Calls {@link beforeFind}. |
|
|
|
* This method is internally used. |
|
|
|
* This method is internally used. |
|
|
|
* @since 1.0.11 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function beforeFindInternal() |
|
|
|
public function beforeFindInternal() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1010,7 +986,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Calls {@link afterFind}. |
|
|
|
* Calls {@link afterFind}. |
|
|
|
* This method is internally used. |
|
|
|
* This method is internally used. |
|
|
|
* @since 1.0.3 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function afterFindInternal() |
|
|
|
public function afterFindInternal() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1153,7 +1128,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @param array $counters the counters to be updated (column name=>increment value) |
|
|
|
* @param array $counters the counters to be updated (column name=>increment value) |
|
|
|
* @return boolean whether the saving is successful |
|
|
|
* @return boolean whether the saving is successful |
|
|
|
* @see updateCounters |
|
|
|
* @see updateCounters |
|
|
|
* @since 1.1.8 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function saveCounters($counters) |
|
|
|
public function saveCounters($counters) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1256,7 +1230,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* After calling this method, the old primary key value can be obtained from {@link oldPrimaryKey}. |
|
|
|
* After calling this method, the old primary key value can be obtained from {@link oldPrimaryKey}. |
|
|
|
* @param mixed $value the new primary key value. If the primary key is composite, the new value |
|
|
|
* @param mixed $value the new primary key value. If the primary key is composite, the new value |
|
|
|
* should be provided as an array (column name=>column value). |
|
|
|
* should be provided as an array (column name=>column value). |
|
|
|
* @since 1.1.0 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function setPrimaryKey($value) |
|
|
|
public function setPrimaryKey($value) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1278,7 +1251,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* The value remains unchanged even if the primary key attribute is manually assigned with a different value. |
|
|
|
* The value remains unchanged even if the primary key attribute is manually assigned with a different value. |
|
|
|
* @return mixed the old primary key value. An array (column name=>column value) is returned if the primary key is composite. |
|
|
|
* @return mixed the old primary key value. An array (column name=>column value) is returned if the primary key is composite. |
|
|
|
* If primary key is not defined, null will be returned. |
|
|
|
* If primary key is not defined, null will be returned. |
|
|
|
* @since 1.1.0 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getOldPrimaryKey() |
|
|
|
public function getOldPrimaryKey() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1288,7 +1260,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the old primary key value. |
|
|
|
* Sets the old primary key value. |
|
|
|
* @param mixed $value the old primary key value. |
|
|
|
* @param mixed $value the old primary key value. |
|
|
|
* @since 1.1.3 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function setOldPrimaryKey($value) |
|
|
|
public function setOldPrimaryKey($value) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1301,7 +1272,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @param CDbCriteria $criteria the query criteria |
|
|
|
* @param CDbCriteria $criteria the query criteria |
|
|
|
* @param boolean $all whether to return all data |
|
|
|
* @param boolean $all whether to return all data |
|
|
|
* @return mixed the AR objects populated with the query result |
|
|
|
* @return mixed the AR objects populated with the query result |
|
|
|
* @since 1.1.7 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function query($criteria, $all = false) |
|
|
|
protected function query($criteria, $all = false) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1326,7 +1296,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This method merges {@link dbCriteria} with the given criteria parameter. |
|
|
|
* This method merges {@link dbCriteria} with the given criteria parameter. |
|
|
|
* It then resets {@link dbCriteria} to be null. |
|
|
|
* It then resets {@link dbCriteria} to be null. |
|
|
|
* @param CDbCriteria $criteria the query criteria. This parameter may be modified by merging {@link dbCriteria}. |
|
|
|
* @param CDbCriteria $criteria the query criteria. This parameter may be modified by merging {@link dbCriteria}. |
|
|
|
* @since 1.0.12 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function applyScopes(&$criteria) |
|
|
|
public function applyScopes(&$criteria) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1382,7 +1351,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This parameter must be set false when calling this method in {@link defaultScope}. |
|
|
|
* This parameter must be set false when calling this method in {@link defaultScope}. |
|
|
|
* An infinite loop would be formed otherwise. |
|
|
|
* An infinite loop would be formed otherwise. |
|
|
|
* @return string the default table alias |
|
|
|
* @return string the default table alias |
|
|
|
* @since 1.1.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getTableAlias($quote = false, $checkScopes = true) |
|
|
|
public function getTableAlias($quote = false, $checkScopes = true) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1396,7 +1364,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the table alias to be used in queries. |
|
|
|
* Sets the table alias to be used in queries. |
|
|
|
* @param string $alias the table alias to be used in queries. The alias should NOT be quoted. |
|
|
|
* @param string $alias the table alias to be used in queries. The alias should NOT be quoted. |
|
|
|
* @since 1.1.3 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function setTableAlias($alias) |
|
|
|
public function setTableAlias($alias) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1578,7 +1545,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @param mixed $condition query condition or criteria. |
|
|
|
* @param mixed $condition query condition or criteria. |
|
|
|
* @param array $params parameters to be bound to an SQL statement. |
|
|
|
* @param array $params parameters to be bound to an SQL statement. |
|
|
|
* @return string the number of rows satisfying the specified query condition. Note: type is string to keep max. precision. |
|
|
|
* @return string the number of rows satisfying the specified query condition. Note: type is string to keep max. precision. |
|
|
|
* @since 1.1.4 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function countByAttributes($attributes, $condition = '', $params = array()) |
|
|
|
public function countByAttributes($attributes, $condition = '', $params = array()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1686,7 +1652,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This is only used in relational AR query. Please refer to {@link CDbCriteria::together} |
|
|
|
* This is only used in relational AR query. Please refer to {@link CDbCriteria::together} |
|
|
|
* for more details. |
|
|
|
* for more details. |
|
|
|
* @return ActiveRecord the AR object itself |
|
|
|
* @return ActiveRecord the AR object itself |
|
|
|
* @since 1.1.4 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function together() |
|
|
|
public function together() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1792,7 +1757,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @param mixed $condition query condition or criteria. |
|
|
|
* @param mixed $condition query condition or criteria. |
|
|
|
* @param array $params parameters to be bound to an SQL statement. |
|
|
|
* @param array $params parameters to be bound to an SQL statement. |
|
|
|
* @return integer number of rows affected by the execution. |
|
|
|
* @return integer number of rows affected by the execution. |
|
|
|
* @since 1.0.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function deleteAllByAttributes($attributes, $condition = '', $params = array()) |
|
|
|
public function deleteAllByAttributes($attributes, $condition = '', $params = array()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1873,7 +1837,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* you may implement the so-called single-table inheritance mapping. |
|
|
|
* you may implement the so-called single-table inheritance mapping. |
|
|
|
* @param array $attributes list of attribute values for the active records. |
|
|
|
* @param array $attributes list of attribute values for the active records. |
|
|
|
* @return ActiveRecord the active record |
|
|
|
* @return ActiveRecord the active record |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function instantiate($attributes) |
|
|
|
protected function instantiate($attributes) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1887,7 +1850,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* This method is required by the interface ArrayAccess. |
|
|
|
* This method is required by the interface ArrayAccess. |
|
|
|
* @param mixed $offset the offset to check on |
|
|
|
* @param mixed $offset the offset to check on |
|
|
|
* @return boolean |
|
|
|
* @return boolean |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function offsetExists($offset) |
|
|
|
public function offsetExists($offset) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1901,7 +1863,6 @@ abstract class ActiveRecord extends \yii\base\Model |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0.4 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CBaseActiveRelation extends CComponent |
|
|
|
class CBaseActiveRelation extends CComponent |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1941,7 +1902,6 @@ class CBaseActiveRelation extends CComponent |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string how to join with other tables. This refers to the JOIN clause in an SQL statement. |
|
|
|
* @var string how to join with other tables. This refers to the JOIN clause in an SQL statement. |
|
|
|
* For example, <code>'LEFT JOIN users ON users.id=authorID'</code>. |
|
|
|
* For example, <code>'LEFT JOIN users ON users.id=authorID'</code>. |
|
|
|
* @since 1.1.3 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $join = ''; |
|
|
|
public $join = ''; |
|
|
|
/** |
|
|
|
/** |
|
|
@ -1975,7 +1935,6 @@ class CBaseActiveRelation extends CComponent |
|
|
|
* Merges this relation with a criteria specified dynamically. |
|
|
|
* Merges this relation with a criteria specified dynamically. |
|
|
|
* @param array $criteria the dynamically specified criteria |
|
|
|
* @param array $criteria the dynamically specified criteria |
|
|
|
* @param boolean $fromScope whether the criteria to be merged is from scopes |
|
|
|
* @param boolean $fromScope whether the criteria to be merged is from scopes |
|
|
|
* @since 1.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function mergeWith($criteria, $fromScope = false) |
|
|
|
public function mergeWith($criteria, $fromScope = false) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2044,7 +2003,6 @@ class CBaseActiveRelation extends CComponent |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0.4 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CStatRelation extends CBaseActiveRelation |
|
|
|
class CStatRelation extends CBaseActiveRelation |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2063,7 +2021,6 @@ class CStatRelation extends CBaseActiveRelation |
|
|
|
* Merges this relation with a criteria specified dynamically. |
|
|
|
* Merges this relation with a criteria specified dynamically. |
|
|
|
* @param array $criteria the dynamically specified criteria |
|
|
|
* @param array $criteria the dynamically specified criteria |
|
|
|
* @param boolean $fromScope whether the criteria to be merged is from scopes |
|
|
|
* @param boolean $fromScope whether the criteria to be merged is from scopes |
|
|
|
* @since 1.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function mergeWith($criteria, $fromScope = false) |
|
|
|
public function mergeWith($criteria, $fromScope = false) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2082,7 +2039,7 @@ class CStatRelation extends CBaseActiveRelation |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0 |
|
|
|
* @since 2.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CActiveRelation extends CBaseActiveRelation |
|
|
|
class CActiveRelation extends CBaseActiveRelation |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2092,13 +2049,11 @@ class CActiveRelation extends CBaseActiveRelation |
|
|
|
public $joinType = 'LEFT OUTER JOIN'; |
|
|
|
public $joinType = 'LEFT OUTER JOIN'; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string ON clause. The condition specified here will be appended to the joining condition using AND operator. |
|
|
|
* @var string ON clause. The condition specified here will be appended to the joining condition using AND operator. |
|
|
|
* @since 1.0.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $on = ''; |
|
|
|
public $on = ''; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string the alias for the table that this relation refers to. Defaults to null, meaning |
|
|
|
* @var string the alias for the table that this relation refers to. Defaults to null, meaning |
|
|
|
* the alias will be the same as the relation name. |
|
|
|
* the alias will be the same as the relation name. |
|
|
|
* @since 1.0.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $alias; |
|
|
|
public $alias; |
|
|
|
/** |
|
|
|
/** |
|
|
@ -2123,7 +2078,6 @@ class CActiveRelation extends CBaseActiveRelation |
|
|
|
* <li>Single scope: 'scopes'=>'scopeName'.</li> |
|
|
|
* <li>Single scope: 'scopes'=>'scopeName'.</li> |
|
|
|
* <li>Multiple scopes: 'scopes'=>array('scopeName1','scopeName2').</li> |
|
|
|
* <li>Multiple scopes: 'scopes'=>array('scopeName1','scopeName2').</li> |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* @since 1.1.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $scopes; |
|
|
|
public $scopes; |
|
|
|
|
|
|
|
|
|
|
@ -2131,7 +2085,6 @@ class CActiveRelation extends CBaseActiveRelation |
|
|
|
* Merges this relation with a criteria specified dynamically. |
|
|
|
* Merges this relation with a criteria specified dynamically. |
|
|
|
* @param array $criteria the dynamically specified criteria |
|
|
|
* @param array $criteria the dynamically specified criteria |
|
|
|
* @param boolean $fromScope whether the criteria to be merged is from scopes |
|
|
|
* @param boolean $fromScope whether the criteria to be merged is from scopes |
|
|
|
* @since 1.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function mergeWith($criteria, $fromScope = false) |
|
|
|
public function mergeWith($criteria, $fromScope = false) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2179,7 +2132,7 @@ class CActiveRelation extends CBaseActiveRelation |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0 |
|
|
|
* @since 2.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CBelongsToRelation extends CActiveRelation |
|
|
|
class CBelongsToRelation extends CActiveRelation |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2191,14 +2144,13 @@ class CBelongsToRelation extends CActiveRelation |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0 |
|
|
|
* @since 2.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CHasOneRelation extends CActiveRelation |
|
|
|
class CHasOneRelation extends CActiveRelation |
|
|
|
{ |
|
|
|
{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string the name of the relation that should be used as the bridge to this relation. |
|
|
|
* @var string the name of the relation that should be used as the bridge to this relation. |
|
|
|
* Defaults to null, meaning don't use any bridge. |
|
|
|
* Defaults to null, meaning don't use any bridge. |
|
|
|
* @since 1.1.7 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $through; |
|
|
|
public $through; |
|
|
|
} |
|
|
|
} |
|
|
@ -2209,7 +2161,7 @@ class CHasOneRelation extends CActiveRelation |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0 |
|
|
|
* @since 2.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CHasManyRelation extends CActiveRelation |
|
|
|
class CHasManyRelation extends CActiveRelation |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2224,13 +2176,11 @@ class CHasManyRelation extends CActiveRelation |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string the name of the column that should be used as the key for storing related objects. |
|
|
|
* @var string the name of the column that should be used as the key for storing related objects. |
|
|
|
* Defaults to null, meaning using zero-based integer IDs. |
|
|
|
* Defaults to null, meaning using zero-based integer IDs. |
|
|
|
* @since 1.0.7 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $index; |
|
|
|
public $index; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string the name of the relation that should be used as the bridge to this relation. |
|
|
|
* @var string the name of the relation that should be used as the bridge to this relation. |
|
|
|
* Defaults to null, meaning don't use any bridge. |
|
|
|
* Defaults to null, meaning don't use any bridge. |
|
|
|
* @since 1.1.7 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $through; |
|
|
|
public $through; |
|
|
|
|
|
|
|
|
|
|
@ -2238,7 +2188,6 @@ class CHasManyRelation extends CActiveRelation |
|
|
|
* Merges this relation with a criteria specified dynamically. |
|
|
|
* Merges this relation with a criteria specified dynamically. |
|
|
|
* @param array $criteria the dynamically specified criteria |
|
|
|
* @param array $criteria the dynamically specified criteria |
|
|
|
* @param boolean $fromScope whether the criteria to be merged is from scopes |
|
|
|
* @param boolean $fromScope whether the criteria to be merged is from scopes |
|
|
|
* @since 1.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function mergeWith($criteria, $fromScope = false) |
|
|
|
public function mergeWith($criteria, $fromScope = false) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2262,7 +2211,7 @@ class CHasManyRelation extends CActiveRelation |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0 |
|
|
|
* @since 2.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CManyManyRelation extends CHasManyRelation |
|
|
|
class CManyManyRelation extends CHasManyRelation |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2275,7 +2224,7 @@ class CManyManyRelation extends CHasManyRelation |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @version $Id: ActiveRecord.php 3344 2011-07-06 22:04:50Z alexander.makarow $ |
|
|
|
* @package system.db.ar |
|
|
|
* @package system.db.ar |
|
|
|
* @since 1.0 |
|
|
|
* @since 2.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class ActiveRecordMetaData |
|
|
|
class ActiveRecordMetaData |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2349,7 +2298,6 @@ class ActiveRecordMetaData |
|
|
|
* @param string $name $name Name of the relation. |
|
|
|
* @param string $name $name Name of the relation. |
|
|
|
* @param array $config $config Relation parameters. |
|
|
|
* @param array $config $config Relation parameters. |
|
|
|
* @return void |
|
|
|
* @return void |
|
|
|
* @since 1.1.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function addRelation($name, $config) |
|
|
|
public function addRelation($name, $config) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2364,7 +2312,6 @@ class ActiveRecordMetaData |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $name $name Name of the relation. |
|
|
|
* @param string $name $name Name of the relation. |
|
|
|
* @return boolean |
|
|
|
* @return boolean |
|
|
|
* @since 1.1.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function hasRelation($name) |
|
|
|
public function hasRelation($name) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2376,7 +2323,6 @@ class ActiveRecordMetaData |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $name $name |
|
|
|
* @param string $name $name |
|
|
|
* @return void |
|
|
|
* @return void |
|
|
|
* @since 1.1.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function removeRelation($name) |
|
|
|
public function removeRelation($name) |
|
|
|
{ |
|
|
|
{ |
|
|
|