Yii Framework v1.1.10 绫诲弬鑰

CDbCriteria

system.db.schema
缁ф壙 class CDbCriteria » CComponent
婧愯嚜 1.0
鐗堟湰 $Id: CDbCriteria.php 3515 2011-12-28 12:29:24Z mdomba $
婧愮爜 framework/db/schema/CDbCriteria.php
CDbCriteria represents a query criteria, such as conditions, ordering by, limit/offset.

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
alias string the alias name of the table. CDbCriteria
condition string query condition. CDbCriteria
distinct boolean whether to select distinct rows of data only. CDbCriteria
group string how to group the query results. CDbCriteria
having string the condition to be applied with GROUP-BY clause. CDbCriteria
index string the name of the AR attribute whose value should be used as index of the query result array. CDbCriteria
join string how to join with other tables. CDbCriteria
limit integer maximum number of records to be returned. CDbCriteria
offset integer zero-based offset from where the records are to be returned. CDbCriteria
order string how to sort the query results. CDbCriteria
paramCount integer the global counter for anonymous binding parameters. CDbCriteria
params array list of query parameter values indexed by parameter placeholders. CDbCriteria
scopes mixed scopes to apply

This property is effective only when passing criteria to the one of the following methods:

Can be set to one of the following:
  • One scope: $criteria->scopes='scopeName';
  • Multiple scopes: $criteria->scopes=array('scopeName1','scopeName2');
  • Scope with parameters: $criteria->scopes=array('scopeName'=>array($params));
  • Multiple scopes with parameters: $criteria->scopes=array('scopeName1'=>array($params1),'scopeName2'=>array($params2));
  • Multiple scopes with the same name: array(array('scopeName'=>array($params1)),array('scopeName'=>array($params2)));
CDbCriteria
select mixed the columns being selected. CDbCriteria
together boolean whether the foreign tables should be joined with the primary table in a single SQL. CDbCriteria
with mixed the relational query criteria. CDbCriteria

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__construct() Constructor. CDbCriteria
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
__wakeup() Remaps criteria parameters on unserialize to prevent name collisions. CDbCriteria
addBetweenCondition() Adds a between condition to the condition property. CDbCriteria
addColumnCondition() Appends a condition for matching the given list of column values. CDbCriteria
addCondition() Appends a condition to the existing condition. CDbCriteria
addInCondition() Appends an IN condition to the existing condition. CDbCriteria
addNotInCondition() Appends an NOT IN condition to the existing condition. CDbCriteria
addSearchCondition() Appends a search condition to the existing condition. CDbCriteria
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
compare() Adds a comparison expression to the condition property. CDbCriteria
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
mergeWith() Merges with another criteria. CDbCriteria
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
toArray() CDbCriteria

灞炴ц缁

alias 灞炴
public string $alias;

the alias name of the table. If not set, it means the alias is 't'.

condition 灞炴
public string $condition;

query condition. This refers to the WHERE clause in an SQL statement. For example, age>31 AND team=1.

distinct 灞炴
public boolean $distinct;

whether to select distinct rows of data only. If this is set true, the SELECT clause would be changed to SELECT DISTINCT.

group 灞炴
public string $group;

how to group the query results. This refers to the GROUP BY clause in an SQL statement. For example, 'projectID, teamID'.

having 灞炴
public string $having;

the condition to be applied with GROUP-BY clause. For example, 'SUM(revenue)<50000'.

index 灞炴 锛堝彲鐢ㄨ嚜 v1.1.5锛
public string $index;

the name of the AR attribute whose value should be used as index of the query result array. Defaults to null, meaning the result array will be zero-based integers.

join 灞炴
public string $join;

how to join with other tables. This refers to the JOIN clause in an SQL statement. For example, 'LEFT JOIN users ON users.id=authorID'.

limit 灞炴
public integer $limit;

maximum number of records to be returned. If less than 0, it means no limit.

offset 灞炴
public integer $offset;

zero-based offset from where the records are to be returned. If less than 0, it means starting from the beginning.

order 灞炴
public string $order;

how to sort the query results. This refers to the ORDER BY clause in an SQL statement.

paramCount 灞炴
public static integer $paramCount;

the global counter for anonymous binding parameters. This counter is used for generating the name for the anonymous parameters.

params 灞炴
public array $params;

list of query parameter values indexed by parameter placeholders. For example, array(':name'=>'Dan', ':age'=>31).

scopes 灞炴 锛堝彲鐢ㄨ嚜 v1.1.7锛
public mixed $scopes;

scopes to apply

This property is effective only when passing criteria to the one of the following methods:



Can be set to one of the following:

select 灞炴
public mixed $select;

the columns being selected. This refers to the SELECT clause in an SQL statement. The property can be either a string (column names separated by commas) or an array of column names. Defaults to '*', meaning all columns.

together 灞炴 锛堝彲鐢ㄨ嚜 v1.1.4锛
public boolean $together;

whether the foreign tables should be joined with the primary table in a single SQL. This property is only used in relational AR queries for HAS_MANY and MANY_MANY relations.

When this property is set true, only a single SQL will be executed for a relational AR query, even if the primary table is limited and the relationship between a foreign table and the primary table is many-to-one.

When this property is set false, a SQL statement will be executed for each HAS_MANY relation.

When this property is not set, if the primary table is limited or paginated, a SQL statement will be executed for each HAS_MANY relation. Otherwise, a single SQL statement will be executed for all.

with 灞炴 锛堝彲鐢ㄨ嚜 v1.1.0锛
public mixed $with;

the relational query criteria. This is used for fetching related objects in eager loading fashion. This property is effective only when the criteria is passed as a parameter to the following methods of CActiveRecord:

The property value will be used as the parameter to the CActiveRecord::with() method to perform the eager loading. Please refer to CActiveRecord::with() on how to specify this parameter.

鏂规硶璇︾粏

__construct() 鏂规硶
public void __construct(array $data=array ( ))
$data array criteria initial property values (indexed by property name)
婧愮爜锛 framework/db/schema/CDbCriteria.php#150 (鏄剧ず)
public function __construct($data=array())
{
    foreach(
$data as $name=>$value)
        
$this->$name=$value;
}

Constructor.

__wakeup() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.9锛
public void __wakeup()
婧愮爜锛 framework/db/schema/CDbCriteria.php#160 (鏄剧ず)
public function __wakeup()
{
    
$map=array();
    
$params=array();
    foreach(
$this->params as $name=>$value)
    {
        
$newName=self::PARAM_PREFIX.self::$paramCount++;
        
$map[$name]=$newName;
        
$params[$newName]=$value;
    }
    
$this->condition=strtr($this->condition,$map);
    
$this->params=$params;
}

Remaps criteria parameters on unserialize to prevent name collisions.

addBetweenCondition() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.2锛
public CDbCriteria addBetweenCondition(string $column, string $valueStart, string $valueEnd, string $operator='AND')
$column string the name of the column to search between.
$valueStart string the beginning value to start the between search.
$valueEnd string the ending value to end the between search.
$operator string the operator used to concatenate the new condition with the existing one. Defaults to 'AND'.
{return} CDbCriteria the criteria object itself
婧愮爜锛 framework/db/schema/CDbCriteria.php#430 (鏄剧ず)
public function addBetweenCondition($column,$valueStart,$valueEnd,$operator='AND')
{
    if(
$valueStart==='' || $valueEnd==='')
        return 
$this;

    
$paramStart=self::PARAM_PREFIX.self::$paramCount++;
    
$paramEnd=self::PARAM_PREFIX.self::$paramCount++;
    
$this->params[$paramStart]=$valueStart;
    
$this->params[$paramEnd]=$valueEnd;
    
$condition="$column BETWEEN $paramStart AND $paramEnd";

    if(
$this->condition==='')
        
$this->condition=$condition;
    else
        
$this->condition='('.$this->condition.') '.$operator.' ('.$condition.')';
    return 
$this;
}

Adds a between condition to the condition property.

The new between condition and the existing condition will be concatenated via the specified operator which defaults to 'AND'. If one or both values are empty then the condition is not added to the existing condition. This method handles the case when the existing condition is empty. After calling this method, the condition property will be modified.

addColumnCondition() 鏂规硶
public CDbCriteria addColumnCondition(array $columns, string $columnOperator='AND', string $operator='AND')
$columns array list of column names and values to be matched (name=>value)
$columnOperator string the operator to concatenate multiple column matching condition. Defaults to 'AND'.
$operator string the operator used to concatenate the new condition with the existing one. Defaults to 'AND'.
{return} CDbCriteria the criteria object itself
婧愮爜锛 framework/db/schema/CDbCriteria.php#316 (鏄剧ず)
public function addColumnCondition($columns,$columnOperator='AND',$operator='AND')
{
    
$params=array();
    foreach(
$columns as $name=>$value)
    {
        if(
$value===null)
            
$params[]=$name.' IS NULL';
        else
        {
            
$params[]=$name.'='.self::PARAM_PREFIX.self::$paramCount;
            
$this->params[self::PARAM_PREFIX.self::$paramCount++]=$value;
        }
    }
    return 
$this->addCondition(implode($columnOperator ",$params), $operator);
}

Appends a condition for matching the given list of column values. The generated condition will be concatenated to the existing condition via the specified operator which defaults to 'AND'. The condition is generated by matching each column and the corresponding value.

addCondition() 鏂规硶
public CDbCriteria addCondition(mixed $condition, string $operator='AND')
$condition mixed the new condition. It can be either a string or an array of strings.
$operator string the operator to join different conditions. Defaults to 'AND'.
{return} CDbCriteria the criteria object itself
婧愮爜锛 framework/db/schema/CDbCriteria.php#186 (鏄剧ず)
public function addCondition($condition,$operator='AND')
{
    if(
is_array($condition))
    {
        if(
$condition===array())
            return 
$this;
        
$condition='('.implode(') '.$operator.' (',$condition).')';
    }
    if(
$this->condition==='')
        
$this->condition=$condition;
    else
        
$this->condition='('.$this->condition.') '.$operator.' ('.$condition.')';
    return 
$this;
}

Appends a condition to the existing condition. The new condition and the existing condition will be concatenated via the specified operator which defaults to 'AND'. The new condition can also be an array. In this case, all elements in the array will be concatenated together via the operator. This method handles the case when the existing condition is empty. After calling this method, the condition property will be modified.

addInCondition() 鏂规硶
public CDbCriteria addInCondition(string $column, array $values, string $operator='AND')
$column string the column name (or a valid SQL expression)
$values array list of values that the column value should be in
$operator string the operator used to concatenate the new condition with the existing one. Defaults to 'AND'.
{return} CDbCriteria the criteria object itself
婧愮爜锛 framework/db/schema/CDbCriteria.php#242 (鏄剧ず)
public function addInCondition($column,$values,$operator='AND')
{
    if((
$n=count($values))<1)
        return 
$this->addCondition('0=1',$operator); // 0=1 is used because in MSSQL value alone can't be used in WHERE
    
if($n===1)
    {
        
$value=reset($values);
        if(
$value===null)
            return 
$this->addCondition($column.' IS NULL');
        
$condition=$column.'='.self::PARAM_PREFIX.self::$paramCount;
        
$this->params[self::PARAM_PREFIX.self::$paramCount++]=$value;
    }
    else
    {
        
$params=array();
        foreach(
$values as $value)
        {
            
$params[]=self::PARAM_PREFIX.self::$paramCount;
            
$this->params[self::PARAM_PREFIX.self::$paramCount++]=$value;
        }
        
$condition=$column.' IN ('.implode(', ',$params).')';
    }
    return 
$this->addCondition($condition,$operator);
}

Appends an IN condition to the existing condition. The IN condition and the existing condition will be concatenated via the specified operator which defaults to 'AND'. The IN condition is generated by using the SQL IN operator which requires the specified column value to be among the given list of values.

addNotInCondition() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.1锛
public CDbCriteria addNotInCondition(string $column, array $values, string $operator='AND')
$column string the column name (or a valid SQL expression)
$values array list of values that the column value should not be in
$operator string the operator used to concatenate the new condition with the existing one. Defaults to 'AND'.
{return} CDbCriteria the criteria object itself
婧愮爜锛 framework/db/schema/CDbCriteria.php#280 (鏄剧ず)
public function addNotInCondition($column,$values,$operator='AND')
{
    if((
$n=count($values))<1)
        return 
$this;
    if(
$n===1)
    {
        
$value=reset($values);
        if(
$value===null)
            return 
$this->addCondition($column.' IS NOT NULL');
        
$condition=$column.'!='.self::PARAM_PREFIX.self::$paramCount;
        
$this->params[self::PARAM_PREFIX.self::$paramCount++]=$value;
    }
    else
    {
        
$params=array();
        foreach(
$values as $value)
        {
            
$params[]=self::PARAM_PREFIX.self::$paramCount;
            
$this->params[self::PARAM_PREFIX.self::$paramCount++]=$value;
        }
        
$condition=$column.' NOT IN ('.implode(', ',$params).')';
    }
    return 
$this->addCondition($condition,$operator);
}

Appends an NOT IN condition to the existing condition. The NOT IN condition and the existing condition will be concatenated via the specified operator which defaults to 'AND'. The NOT IN condition is generated by using the SQL NOT IN operator which requires the specified column value to be among the given list of values.

addSearchCondition() 鏂规硶
public CDbCriteria addSearchCondition(string $column, string $keyword, boolean $escape=true, string $operator='AND', string $like='LIKE')
$column string the column name (or a valid SQL expression)
$keyword string the search keyword. This interpretation of the keyword is affected by the next parameter.
$escape boolean whether the keyword should be escaped if it contains characters % or _. When this parameter is true (default), the special characters % (matches 0 or more characters) and _ (matches a single character) will be escaped, and the keyword will be surrounded with a % character on both ends. When this parameter is false, the keyword will be directly used for matching without any change.
$operator string the operator used to concatenate the new condition with the existing one. Defaults to 'AND'.
$like string the LIKE operator. Defaults to 'LIKE'. You may also set this to be 'NOT LIKE'.
{return} CDbCriteria the criteria object itself
婧愮爜锛 framework/db/schema/CDbCriteria.php#219 (鏄剧ず)
public function addSearchCondition($column,$keyword,$escape=true,$operator='AND',$like='LIKE')
{
    if(
$keyword=='')
        return 
$this;
    if(
$escape)
        
$keyword='%'.strtr($keyword,array('%'=>'\%''_'=>'\_''\\'=>'\\\\')).'%';
    
$condition=$column.$like ".self::PARAM_PREFIX.self::$paramCount;
    
$this->params[self::PARAM_PREFIX.self::$paramCount++]=$keyword;
    return 
$this->addCondition($condition$operator);
}

Appends a search condition to the existing condition. The search condition and the existing condition will be concatenated via the specified operator which defaults to 'AND'. The search condition is generated using the SQL LIKE operator with the given column name and search keyword.

compare() 鏂规硶 锛堝彲鐢ㄨ嚜 v1.1.1锛
public CDbCriteria compare(string $column, mixed $value, boolean $partialMatch=false, string $operator='AND', boolean $escape=true)
$column string the name of the column to be searched
$value mixed the column value to be compared with. If the value is a string, the aforementioned intelligent comparison will be conducted. If the value is an array, the comparison is done by exact match of any of the value in the array. If the string or the array is empty, the existing search condition will not be modified.
$partialMatch boolean whether the value should consider partial text match (using LIKE and NOT LIKE operators). Defaults to false, meaning exact comparison.
$operator string the operator used to concatenate the new condition with the existing one. Defaults to 'AND'.
$escape boolean whether the value should be escaped if $partialMatch is true and the value contains characters % or _. When this parameter is true (default), the special characters % (matches 0 or more characters) and _ (matches a single character) will be escaped, and the value will be surrounded with a % character on both ends. When this parameter is false, the value will be directly used for matching without any change.
{return} CDbCriteria the criteria object itself
婧愮爜锛 framework/db/schema/CDbCriteria.php#376 (鏄剧ず)
public function compare($column$value$partialMatch=false$operator='AND'$escape=true)
{
    if(
is_array($value))
    {
        if(
$value===array())
            return 
$this;
        return 
$this->addInCondition($column,$value,$operator);
    }
    else
        
$value="$value";

    if(
preg_match('/^(?:\s*(<>|<=|>=|<|>|=))?(.*)$/',$value,$matches))
    {
        
$value=$matches[2];
        
$op=$matches[1];
    }
    else
        
$op='';

    if(
$value==='')
        return 
$this;

    if(
$partialMatch)
    {
        if(
$op==='')
            return 
$this->addSearchCondition($column,$value,$escape,$operator);
        if(
$op==='<>')
            return 
$this->addSearchCondition($column,$value,$escape,$operator,'NOT LIKE');
    }
    else if(
$op==='')
        
$op='=';

    
$this->addCondition($column.$op.self::PARAM_PREFIX.self::$paramCount,$operator);
    
$this->params[self::PARAM_PREFIX.self::$paramCount++]=$value;

    return 
$this;
}

Adds a comparison expression to the condition property.

This method is a helper that appends to the condition property with a new comparison expression. The comparison is done by comparing a column with the given value using some comparison operator.

The comparison operator is intelligently determined based on the first few characters in the given value. In particular, it recognizes the following operators if they appear as the leading characters in the given value:



Note that any surrounding white spaces will be removed from the value before comparison. When the value is empty, no comparison expression will be added to the search condition.

mergeWith() 鏂规硶
public void mergeWith(mixed $criteria, boolean $useAnd=true)
$criteria mixed the criteria to be merged with. Either an array or CDbCriteria.
$useAnd boolean whether to use 'AND' to merge condition and having options. If false, 'OR' will be used instead. Defaults to 'AND'.
婧愮爜锛 framework/db/schema/CDbCriteria.php#458 (鏄剧ず)
public function mergeWith($criteria,$useAnd=true)
{
    
$and=$useAnd 'AND' 'OR';
    if(
is_array($criteria))
        
$criteria=new self($criteria);
    if(
$this->select!==$criteria->select)
    {
        if(
$this->select==='*')
            
$this->select=$criteria->select;
        else if(
$criteria->select!=='*')
        {
            
$select1=is_string($this->select)?preg_split('/\s*,\s*/',trim($this->select),-1,PREG_SPLIT_NO_EMPTY):$this->select;
            
$select2=is_string($criteria->select)?preg_split('/\s*,\s*/',trim($criteria->select),-1,PREG_SPLIT_NO_EMPTY):$criteria->select;
            
$this->select=array_merge($select1,array_diff($select2,$select1));
        }
    }

    if(
$this->condition!==$criteria->condition)
    {
        if(
$this->condition==='')
            
$this->condition=$criteria->condition;
        else if(
$criteria->condition!=='')
            
$this->condition="({$this->condition}$and ({$criteria->condition})";
    }

    if(
$this->params!==$criteria->params)
        
$this->params=array_merge($this->params,$criteria->params);

    if(
$criteria->limit>0)
        
$this->limit=$criteria->limit;

    if(
$criteria->offset>=0)
        
$this->offset=$criteria->offset;

    if(
$criteria->alias!==null)
        
$this->alias=$criteria->alias;

    if(
$this->order!==$criteria->order)
    {
        if(
$this->order==='')
            
$this->order=$criteria->order;
        else if(
$criteria->order!=='')
            
$this->order=$criteria->order.', '.$this->order;
    }

    if(
$this->group!==$criteria->group)
    {
        if(
$this->group==='')
            
$this->group=$criteria->group;
        else if(
$criteria->group!=='')
            
$this->group.=', '.$criteria->group;
    }

    if(
$this->join!==$criteria->join)
    {
        if(
$this->join==='')
            
$this->join=$criteria->join;
        else if(
$criteria->join!=='')
            
$this->join.=' '.$criteria->join;
    }

    if(
$this->having!==$criteria->having)
    {
        if(
$this->having==='')
            
$this->having=$criteria->having;
        else if(
$criteria->having!=='')
            
$this->having="({$this->having}$and ({$criteria->having})";
    }

    if(
$criteria->distinct>0)
        
$this->distinct=$criteria->distinct;

    if(
$criteria->together!==null)
        
$this->together=$criteria->together;

    if(
$criteria->index!==null)
        
$this->index=$criteria->index;

    if(empty(
$this->scopes))
        
$this->scopes=$criteria->scopes;
    else if(!empty(
$criteria->scopes))
    {
        
$scopes1=(array)$this->scopes;
        
$scopes2=(array)$criteria->scopes;
        foreach(
$scopes1 as $k=>$v)
        {
            if(
is_integer($k))
                
$scopes[]=$v;
            else if(isset(
$scopes2[$k]))
                
$scopes[]=array($k=>$v);
            else
                
$scopes[$k]=$v;
        }
        foreach(
$scopes2 as $k=>$v)
        {
            if(
is_integer($k))
                
$scopes[]=$v;
            else if(isset(
$scopes1[$k]))
                
$scopes[]=array($k=>$v);
            else
                
$scopes[$k]=$v;
        }
        
$this->scopes=$scopes;
    }

    if(empty(
$this->with))
        
$this->with=$criteria->with;
    else if(!empty(
$criteria->with))
    {
        
$this->with=(array)$this->with;
        foreach((array)
$criteria->with as $k=>$v)
        {
            if(
is_integer($k))
                
$this->with[]=$v;
            else if(isset(
$this->with[$k]))
            {
                
$excludes=array();
                foreach(array(
'joinType','on') as $opt)
                {
                    if(isset(
$this->with[$k][$opt]))
                        
$excludes[$opt]=$this->with[$k][$opt];
                    if(isset(
$v[$opt]))
                        
$excludes[$opt]= ($opt==='on' && isset($excludes[$opt]) && $v[$opt]!==$excludes[$opt]) ?
                            
"($excludes[$opt]) AND $v[$opt]$v[$opt];
                    unset(
$this->with[$k][$opt]);
                    unset(
$v[$opt]);
                }
                
$this->with[$k]=new self($this->with[$k]);
                
$this->with[$k]->mergeWith($v,$useAnd);
                
$this->with[$k]=$this->with[$k]->toArray();
                if (
count($excludes)!==0)
                    
$this->with[$k]=CMap::mergeArray($this->with[$k],$excludes);
            }
            else
                
$this->with[$k]=$v;
        }
    }
}

Merges with another criteria. In general, the merging makes the resulting criteria more restrictive. For example, if both criterias have conditions, they will be 'AND' together. Also, the criteria passed as the parameter takes precedence in case two options cannot be merged (e.g. LIMIT, OFFSET).

toArray() 鏂规硶
public array toArray()
{return} array the array representation of the criteria
婧愮爜锛 framework/db/schema/CDbCriteria.php#600 (鏄剧ず)
public function toArray()
{
    
$result=array();
    foreach(array(
'select''condition''params''limit''offset''order''group''join''having''distinct''scopes''with''alias''index''together') as $name)
        
$result[$name]=$this->$name;
    return 
$result;
}

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.