为什么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 个回复
峨躬坎抬焚
。你的应用程序必须在你的一个控制器中的某个型号上调用
(可能是你的AppController,因为每个页面调用它,或者检查你的beforeFilters)。