Yii Framework v1.1.10 绫诲弬鑰

CDbCacheDependency

system.caching.dependencies
缁ф壙 class CDbCacheDependency » CCacheDependency » CComponent
瀹炵幇 ICacheDependency
婧愯嚜 1.0
鐗堟湰 $Id: CDbCacheDependency.php 3204 2011-05-05 21:36:32Z alexander.makarow $
婧愮爜 framework/caching/dependencies/CDbCacheDependency.php
CDbCacheDependency鎸囧熀浜嶴QL璇彞鏌ヨ缁撴灉鐨勪緷璧栭」銆

鑻ユ煡璇㈢粨鏋滐紙涓涓噺锛夋敼鍙樹簡锛屽垯璁や负璇ヤ緷璧栭」鏀瑰彉銆 璁剧疆sql灞炴т互鎸囧畾SQL璇彞銆 connectionID灞炴ф寚瀹氫簡CDbConnection搴旂敤缁勪欢鐨処D銆 瀹冩槸鐢ㄦ潵鎵ц鏌ヨ鐨勬暟鎹簱杩炴帴銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
connectionID string CDbConnection搴旂敤缁勪欢鐨処D銆傞粯璁ゆ槸鈥榙b鈥欍 CDbCacheDependency
dependentData mixed 鐢ㄤ互鍐冲畾渚濊禆椤规槸鍚﹁鏀瑰彉鐨勬暟鎹 杩欎簺鏁版嵁鏄彲鐢ㄧ殑鍦evaluateDependency琚皟鐢ㄥ悗銆 CCacheDependency
hasChanged boolean 渚濊禆椤规槸鍚﹁鏀瑰彉銆 CCacheDependency
params array 缁戝畾鍒sql鎸囧畾鐨凷QL璇彞鐨勫弬鏁帮紙鍚=>鍊硷級銆 CDbCacheDependency
sql string SQL璇彞锛屽畠鐨勬煡璇㈢粨鏋滅敤鏉ュ喅瀹氫緷璧栭」鏄惁琚敼鍙樸 娉ㄦ剰锛岃SQL璇彞搴旇杩斿洖涓涓崟涓鐨勫笺 CDbCacheDependency

鍙椾繚鎶ゅ睘鎬

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
dbConnection CDbConnection 鏁版嵁搴撹繛鎺ュ疄渚嬨 CDbCacheDependency

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__construct() 鏋勯犲櫒銆 CDbCacheDependency
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__sleep() PHP鐨勯瓟鏈柟娉晄leep銆 CDbCacheDependency
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateDependency() 鏍规嵁渚濊禆鍏崇郴鏉ョ敓瀛樺拰淇濆瓨鏁版嵁浠ヨ绠椾緷璧栭」銆 CCacheDependency
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getDependentData() 杩斿洖鐢ㄤ互鍐冲畾渚濊禆椤规槸鍚﹁鏀瑰彉鐨勬暟鎹 杩欎簺鏁版嵁鏄彲鐢ㄧ殑鍦evaluateDependency琚皟鐢ㄥ悗銆 CCacheDependency
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getHasChanged() 杩斿洖渚濊禆椤规槸鍚﹁鏀瑰彉銆 CCacheDependency
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
generateDependentData() 鐢熸垚鍐冲畾渚濊禆椤规槸鍚﹁鏀瑰彉闇瑕佺殑鏁版嵁銆 CDbCacheDependency
getDbConnection() 杩斿洖鏁版嵁搴撹繛鎺ュ疄渚嬨 CDbCacheDependency

灞炴ц缁

connectionID 灞炴
public string $connectionID;

CDbConnection搴旂敤缁勪欢鐨処D銆傞粯璁ゆ槸鈥榙b鈥欍

dbConnection 灞炴 鍙

鏁版嵁搴撹繛鎺ュ疄渚嬨

params 灞炴 锛堝彲鐢ㄨ嚜 v1.1.4锛
public array $params;

缁戝畾鍒sql鎸囧畾鐨凷QL璇彞鐨勫弬鏁帮紙鍚=>鍊硷級銆

sql 灞炴
public string $sql;

SQL璇彞锛屽畠鐨勬煡璇㈢粨鏋滅敤鏉ュ喅瀹氫緷璧栭」鏄惁琚敼鍙樸 娉ㄦ剰锛岃SQL璇彞搴旇杩斿洖涓涓崟涓鐨勫笺

鏂规硶璇︾粏

__construct() 鏂规硶
public void __construct(string $sql=NULL)
$sql string SQL璇彞锛屽畠鐨勬煡璇㈢粨鏋滅敤鏉ュ喅瀹氫緷璧栭」鏄惁琚敼鍙樸
婧愮爜锛 framework/caching/dependencies/CDbCacheDependency.php#47 (鏄剧ず)
public function __construct($sql=null)
{
    
$this->sql=$sql;
}

鏋勯犲櫒銆

__sleep() 鏂规硶
public array __sleep()
{return} array
婧愮爜锛 framework/caching/dependencies/CDbCacheDependency.php#57 (鏄剧ず)
public function __sleep()
{
    
$this->_db=null;
    return 
array_keys((array)$this);
}

PHP鐨勯瓟鏈柟娉晄leep銆 璇ユ柟娉曚繚璇佹暟鎹簱瀹炰緥鏄痭ull锛屽洜涓哄畠鍖呭惈浜嗚祫婧愬彞鏌勩

generateDependentData() 鏂规硶
protected mixed generateDependentData()
{return} mixed 鍐冲畾渚濊禆椤规槸鍚﹁鏀瑰彉闇瑕佺殑鏁版嵁銆
婧愮爜锛 framework/caching/dependencies/CDbCacheDependency.php#68 (鏄剧ず)
protected function generateDependentData()
{
    if(
$this->sql!==null)
    {
        
$db=$this->getDbConnection();
        
$command=$db->createCommand($this->sql);
        if(
is_array($this->params))
        {
            foreach(
$this->params as $name=>$value)
                
$command->bindValue($name,$value);
        }
        if(
$db->queryCachingDuration>0)
        {
            
// temporarily disable and re-enable query caching
            
$duration=$db->queryCachingDuration;
            
$db->queryCachingDuration=0;
            
$result=$command->queryRow();
            
$db->queryCachingDuration=$duration;
        }
        else
            
$result=$command->queryRow();
        return 
$result;
    }
    else
        throw new 
CException(Yii::t('yii','CDbCacheDependency.sql cannot be empty.'));
}

鐢熸垚鍐冲畾渚濊禆椤规槸鍚﹁鏀瑰彉闇瑕佺殑鏁版嵁銆 璇ユ柟娉曡繑鍥炲叏灞鐘舵佺殑鍊笺

getDbConnection() 鏂规硶
protected CDbConnection getDbConnection()
{return} CDbConnection 鏁版嵁搴撹繛鎺ュ疄渚嬨
婧愮爜锛 framework/caching/dependencies/CDbCacheDependency.php#99 (鏄剧ず)
protected function getDbConnection()
{
    if(
$this->_db!==null)
        return 
$this->_db;
    else
    {
        if((
$this->_db=Yii::app()->getComponent($this->connectionID)) instanceof CDbConnection)
            return 
$this->_db;
        else
            throw new 
CException(Yii::t('yii','CDbCacheDependency.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.',
                array(
'{id}'=>$this->connectionID)));
    }
}

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