framework/db/ar/CActiveFinder.php
public function lazyFind($baseRecord)
	{
		if(is_string($this->_table->primaryKey))
			$this->records[$baseRecord->{$this->_table->primaryKey}]=$baseRecord;
		else
		{
			$pk=array();
			foreach($this->_table->primaryKey as $name)
				$pk[$name]=$baseRecord->$name;
			$this->records[serialize($pk)]=$baseRecord;
		}

		foreach($this->stats as $stat)
			$stat->query();

		if(!$this->children)
			return;

		$params=array();
		foreach($this->children as $child)
			if(is_array($child->relation->params))
				$params=array_merge($params,$child->relation->params);

		$query=new CJoinQuery($child);
		$query->selects=array($child->getColumnSelect($child->relation->select));
		$query->conditions=array(
			$child->relation->on,
		);
		$query->groups[]=$child->relation->group;
		$query->joins[]=$child->relation->join;
		$query->havings[]=$child->relation->having;
		$query->orders[]=$child->relation->order;
		$query->params=$params;
		$query->elements[$child->id]=true;
		if($child->relation instanceof CHasManyRelation)
		{
			$query->limit=$child->relation->limit;
			$query->offset=$child->relation->offset;
		}

		$child->applyLazyCondition($query,$baseRecord);

		$this->_joined=true;
		$child->_joined=true;

		$this->_finder->baseLimited=false;
		$child->buildQuery($query);
		$child->runQuery($query);
		foreach($child->children as $c)
			$c->find();

		if(empty($child->records))
			return;
		if($child->relation instanceof CHasOneRelation || $child->relation instanceof CBelongsToRelation)
			$baseRecord->addRelatedRecord($child->relation->name,reset($child->records),false);
		else // has_many and many_many
		{
			foreach($child->records as $record)
			{
				if($child->relation->index!==null)
					$index=$record->{$child->relation->index};
				else
					$index=true;
				$baseRecord->addRelatedRecord($child->relation->name,$record,$index);
			}
		}
	}
public function lazyFind($baseRecord)
	{
		if(is_string($this->_table->primaryKey))
			$this->records[$baseRecord->{$this->_table->primaryKey}]=$baseRecord;
		else
		{
			$pk=array();
			foreach($this->_table->primaryKey as $name)
				$pk[$name]=$baseRecord->$name;
			$this->records[serialize($pk)]=$baseRecord;
		}

		foreach($this->stats as $stat)
			$stat->query();

		if(!$this->children)
			return;

		$params=array();
		foreach($this->children as $child)
			if(is_array($child->relation->params))
				$params=array_merge($params,$child->relation->params);

		$query=new CJoinQuery($child);
		$query->selects=array($child->getColumnSelect($child->relation->select));
		$query->conditions=array(
			$child->relation->on,
		);
		$query->groups[]=$child->relation->group;
		$query->joins[]=$child->relation->join;
		$query->havings[]=$child->relation->having;
		$query->orders[]=$child->relation->order;
		$query->params=$params;
		$query->elements[$child->id]=true;
		if($child->relation instanceof CHasManyRelation)
		{
			$query->limit=$child->relation->limit;
			$query->offset=$child->relation->offset;
		}

		$child->applyLazyCondition($query,$baseRecord);

		$this->_joined=true;
		$child->_joined=true;

		$this->_finder->baseLimited=false;
		$child->buildQuery($query);
		$child->runQuery($query);
		foreach($child->children as $c)
			$c->find();

		if(empty($child->records))
			return;
		if($child->relation instanceof CHasOneRelation || $child->relation instanceof CBelongsToRelation)
			$baseRecord->addRelatedRecord($child->relation->name,reset($child->records),false);
		else // has_many and many_many
		{
			foreach($child->records as $record)
			{
				if($child->relation->index!==null)
					$index=$record->{$child->relation->index};
				else
					$index=true;
				$baseRecord->addRelatedRecord($child->relation->name,$record,$index);
			}
		}
	}
public function lazyFind ( $ baseRecord ) { if ( is_string ( $ this -> _table -> primaryKey ) ) $ this -> records [ $ baseRecord -> { $ this -> _table -> primaryKey } ] = $ baseRecord ; else { $ pk = array ( ) ; foreach ( $ this -> _table -> primaryKey as $ name ) $ pk [ $ name ] = $ baseRecord -> $ name ; $ this -> records [ serialize ( $ pk ) ] = $ baseRecord ; } foreach ( $ this -> stats as $ stat ) $ stat -> query ( ) ; if ( ! $ this -> children ) return ; $ params = array ( ) ; foreach ( $ this -> children as $ child ) if ( is_array ( $ child -> relation -> params ) ) $ params = array_merge ( $ params , $ child -> relation -> params ) ; $ query = new CJoinQuery ( $ child ) ; $ query -> selects = array ( $ child -> getColumnSelect ( $ child -> relation -> select ) ) ; $ query -> conditions = array ( $ child -> relation -> on , ) ; $ query -> groups [ ] = $ child -> relation -> group ; $ query -> joins [ ] = $ child -> relation -> join ; $ query -> havings [ ] = $ child -> relation -> having ; $ query -> orders [ ] = $ child -> relation -> order ; $ query -> params = $ params ; $ query -> elements [ $ child -> id ] = true ; if ( $ child -> relation instanceof CHasManyRelation ) { $ query -> limit = $ child -> relation -> limit ; $ query -> offset = $ child -> relation -> offset ; } $ child -> applyLazyCondition ( $ query , $ baseRecord ) ; $ this -> _joined = true ; $ child -> _joined = true ; $ this -> _finder -> baseLimited = false ; $ child -> buildQuery ( $ query ) ; $ child -> runQuery ( $ query ) ; foreach ( $ child -> children as $ c ) $ c -> find ( ) ; if ( empty ( $ child -> records ) ) return ; if ( $ child -> relation instanceof CHasOneRelation || $ child -> relation instanceof CBelongsToRelation ) $ baseRecord -> addRelatedRecord ( $ child -> relation -> name , reset ( $ child -> records ) , false ) ; else // has_many and many_many { foreach ( $ child -> records as $ record ) { if ( $ child -> relation -> index !== null ) $ index = $ record -> { $ child -> relation -> index } ; else $ index = true ; $ baseRecord -> addRelatedRecord ( $ child -> relation -> name , $ record , $ index ) ; } } }
Performs lazy find with the specified base record.
@param CActiveRecord $baseRecord the active record whose related object is to be fetched.
Performs lazy find with the specified base record .