2011-01-05 3 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을 실행하지 않습니다. 귀하의 컨트롤러 중 하나 (일부 AppController는 모든 페이지에 대해 호출되거나 beforeFilters를 확인하기 때문에)의 일부 모델에서 앱이 save을 호출해야합니다.

관련 문제