CActiveFinder
鍖 | system.db.ar |
---|---|
缁ф壙 | class CActiveFinder » CComponent |
婧愯嚜 | 1.0 |
鐗堟湰 | $Id: CActiveFinder.php 3562 2012-02-13 01:27:06Z qiang.xue $ |
婧愮爜 | framework/db/ar/CActiveFinder.php |
鍏叡灞炴
灞炴 | 绫诲瀷 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|---|
baseLimited | boolean | 鍩虹妯″瀷鏈夊惁闄愬埗鎴栧亸绉汇 鍦ㄥ唴閮ㄤ娇鐢ㄦ灞炴 | CActiveFinder |
joinAll | boolean | 涓娆″叏閮ㄨ繛鎺ユ墍鏈夎〃銆傞粯璁や负false銆 鍦ㄥ唴閮ㄤ娇鐢ㄦ灞炴с | CActiveFinder |
鍏叡鏂规硶
鏂规硶 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|
__call() | 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 | CComponent |
__construct() | 鏋勯犲嚱鏁般 | CActiveFinder |
__get() | 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 | CComponent |
__isset() | 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 | CComponent |
__set() | 璁剧疆涓涓粍浠剁殑灞炴у笺 | CComponent |
__unset() | 璁剧疆涓涓粍浠剁殑灞炴т负null銆 | CComponent |
asa() | 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° | CComponent |
attachBehavior() | 闄勫姞涓涓涓哄埌缁勪欢銆 | CComponent |
attachBehaviors() | 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 | CComponent |
attachEventHandler() | 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 | CComponent |
canGetProperty() | 纭畾灞炴ф槸鍚﹀彲璇汇 | CComponent |
canSetProperty() | 纭畾灞炴ф槸鍚﹀彲鍐欍 | CComponent |
count() | 姝ゆ柟娉曞湪鍐呴儴琚皟鐢ㄣ | CActiveFinder |
detachBehavior() | 浠庣粍浠朵腑鍒嗙涓涓涓恒 | CComponent |
detachBehaviors() | 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 | CComponent |
detachEventHandler() | 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 | CComponent |
disableBehavior() | 绂佺敤涓涓檮鍔犺涓恒 | CComponent |
disableBehaviors() | 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
enableBehavior() | 鍚敤涓涓檮鍔犺涓恒 | CComponent |
enableBehaviors() | 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
evaluateExpression() | 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 | CComponent |
findAllBySql() | 姝ゆ柟娉曞湪鍐呴儴琚皟鐢ㄣ | CActiveFinder |
findBySql() | 姝ゆ柟娉曞湪鍐呴儴琚皟鐢ㄣ | CActiveFinder |
getEventHandlers() | 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 | CComponent |
hasEvent() | 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 | CComponent |
hasEventHandler() | 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 | CComponent |
hasProperty() | 纭畾灞炴ф槸鍚﹁瀹氫箟銆 | CComponent |
lazyFind() | 鏌ユ壘鎸囧畾娲诲姩璁板綍鐨勭浉鍏冲璞° | CActiveFinder |
query() | 涓嶈璋冪敤杩欎釜鏂规硶銆 姝ゆ柟娉曞湪鍐呴儴浣跨敤浠ユ墽琛屽叧鑱旀煡璇€ | CActiveFinder |
raiseEvent() | 鍙戣捣涓涓簨浠躲 | CComponent |
灞炴ц缁
baseLimited
灞炴
public boolean $baseLimited;
鍩虹妯″瀷鏈夊惁闄愬埗鎴栧亸绉汇 鍦ㄥ唴閮ㄤ娇鐢ㄦ灞炴
joinAll
灞炴
public boolean $joinAll;
涓娆″叏閮ㄨ繛鎺ユ墍鏈夎〃銆傞粯璁や负false銆 鍦ㄥ唴閮ㄤ娇鐢ㄦ灞炴с
鏂规硶璇︾粏
__construct()
鏂规硶
public void __construct(CActiveRecord $model, mixed $with)
| ||
$model | CActiveRecord | 鍒濆鍖朼ctive finding process鐨刴odel |
$with | mixed | 瀹炴椂鏌ヨ鐨勫叧绯诲悕 |
婧愮爜锛 framework/db/ar/CActiveFinder.php#45 (鏄剧ず)
public function __construct($model,$with)
{
$this->_builder=$model->getCommandBuilder();
$this->_joinTree=new CJoinElement($this,$model);
$this->buildJoinTree($this->_joinTree,$with);
}
鏋勯犲嚱鏁般 涓涓猨oin鏍戠殑寤虹珛鍩轰簬澹版槑鐨勬椿鍔ㄨ褰曚箣闂寸殑鍏崇郴銆
count()
鏂规硶
public string count(CDbCriteria $criteria)
| ||
$criteria | CDbCriteria | 鏌ヨ鏉′欢 |
{return} | string |
婧愮爜锛 framework/db/ar/CActiveFinder.php#146 (鏄剧ず)
public function count($criteria)
{
Yii::trace(get_class($this->_joinTree->model).'.count() eagerly','system.db.ar.CActiveRecord');
$this->joinAll=$criteria->together!==true;
$alias=$criteria->alias===null ? 't' : $criteria->alias;
$this->_joinTree->tableAlias=$alias;
$this->_joinTree->rawTableAlias=$this->_builder->getSchema()->quoteTableName($alias);
$n=$this->_joinTree->count($criteria);
$this->destroyJoinTree();
return $n;
}
姝ゆ柟娉曞湪鍐呴儴琚皟鐢ㄣ
findAllBySql()
鏂规硶
public CActiveRecord[] findAllBySql(string $sql, array $params=array (
))
| ||
$sql | string | SQL 璇彞 |
$params | array | 缁戝畾 SQL 璇彞鐨勫弬鏁 |
{return} | CActiveRecord[] |
婧愮爜锛 framework/db/ar/CActiveFinder.php#122 (鏄剧ず)
public function findAllBySql($sql,$params=array())
{
Yii::trace(get_class($this->_joinTree->model).'.findAllBySql() eagerly','system.db.ar.CActiveRecord');
if(($rows=$this->_builder->createSqlCommand($sql,$params)->queryAll())!==array())
{
$baseRecords=$this->_joinTree->model->populateRecords($rows,false);
$this->_joinTree->beforeFind(false);
$this->_joinTree->findWithBase($baseRecords);
$this->_joinTree->afterFind();
$this->destroyJoinTree();
return $baseRecords;
}
else
{
$this->destroyJoinTree();
return array();
}
}
姝ゆ柟娉曞湪鍐呴儴琚皟鐢ㄣ
findBySql()
鏂规硶
public CActiveRecord findBySql(string $sql, array $params=array (
))
| ||
$sql | string | SQL 璇彞 |
$params | array | 鍙傛暟缁戝畾鍒版 SQL 璇彞 |
{return} | CActiveRecord |
婧愮爜锛 framework/db/ar/CActiveFinder.php#100 (鏄剧ず)
public function findBySql($sql,$params=array())
{
Yii::trace(get_class($this->_joinTree->model).'.findBySql() eagerly','system.db.ar.CActiveRecord');
if(($row=$this->_builder->createSqlCommand($sql,$params)->queryRow())!==false)
{
$baseRecord=$this->_joinTree->model->populateRecord($row,false);
$this->_joinTree->beforeFind(false);
$this->_joinTree->findWithBase($baseRecord);
$this->_joinTree->afterFind();
$this->destroyJoinTree();
return $baseRecord;
}
else
$this->destroyJoinTree();
}
姝ゆ柟娉曞湪鍐呴儴琚皟鐢ㄣ
lazyFind()
鏂规硶
public void lazyFind(CActiveRecord $baseRecord)
| ||
$baseRecord | CActiveRecord | 瑕佽杞藉叆鐨勫熀鏈褰曠浉鍏冲璞 |
婧愮爜锛 framework/db/ar/CActiveFinder.php#165 (鏄剧ず)
public function lazyFind($baseRecord)
{
$this->_joinTree->lazyFind($baseRecord);
if(!empty($this->_joinTree->children))
{
$child=reset($this->_joinTree->children);
$child->afterFind();
}
$this->destroyJoinTree();
}
鏌ユ壘鎸囧畾娲诲姩璁板綍鐨勭浉鍏冲璞° 璇ユ柟娉曞湪鍐呴儴琚CActiveRecord瑙﹀彂锛屾敮鎸佹噿鎯板姞杞.
query()
鏂规硶
public mixed query(CDbCriteria $criteria, boolean $all=false)
| ||
$criteria | CDbCriteria | 璇ユ暟鎹簱鏉′欢 |
$all | boolean | 鏄惁甯﹀洖鎵鏈夎褰 |
{return} | mixed | 鏌ヨ缁撴灉 |
婧愮爜锛 framework/db/ar/CActiveFinder.php#59 (鏄剧ず)
public function query($criteria,$all=false)
{
$this->joinAll=$criteria->together===true;
$this->_joinTree->beforeFind(false);
if($criteria->alias!='')
{
$this->_joinTree->tableAlias=$criteria->alias;
$this->_joinTree->rawTableAlias=$this->_builder->getSchema()->quoteTableName($criteria->alias);
}
$this->_joinTree->find($criteria);
$this->_joinTree->afterFind();
if($all)
{
$result = array_values($this->_joinTree->records);
if ($criteria->index!==null)
{
$index=$criteria->index;
$array=array();
foreach($result as $object)
$array[$object->$index]=$object;
$result=$array;
}
}
else if(count($this->_joinTree->records))
$result = reset($this->_joinTree->records);
else
$result = null;
$this->destroyJoinTree();
return $result;
}
涓嶈璋冪敤杩欎釜鏂规硶銆 姝ゆ柟娉曞湪鍐呴儴浣跨敤浠ユ墽琛屽叧鑱旀煡璇€ 鍩轰簬缁欏畾鐨勬暟鎹簱鏉′欢銆