2011-01-05 27 views
0

爲什麼app_model.php中的afterSave()總是觸發每個頁面加載?爲什麼app_model.php中的afterSave()總是觸發?

class AppModel extends Model 
{ 
    public $cacheQueries = true;  
    var $actsAs = array('Containable'); 

    function __construct($id = false, $table = null, $ds = null) { 
     parent::__construct($id, $table, $ds); 
    } 

    function afterSave($created) { 
     // Is used for better workflow when saving data 
     // Just for update 
     if(!$created) { 
      $_SESSION['redirect_update'] = true; 
      $_SESSION['redirect_to']  = $_SESSION['form_referer']; 
      debug('im always show on every page load!'); 
     } 
    } 

} 

回答

1

剛剛檢查了Cake的全新安裝。 AppModel在每次加載頁面時都不會觸發afterSave。您的應用程序必須在您的某個控制器的某個模型上調用save(可能是您的AppController,因爲它是針對每個頁面調用的,或者檢查您的beforeFilters)。

相關問題