CakePHP 2.x afterSave() return 值
CakePHP 2.x afterSave() return value
我正在使用 afterSave() 回调来清除我的模型的一些缓存查询。我检查了文档,但没有说明 TRUE/FALSE 是否应该 returned。对于 beforeSave(),您需要 return TRUE/FALSE。回调 header 如下所示:
afterSave(boolean $created, array $options = array())
我最初的想法是我应该 return $created 但它只是不清楚。对此有什么想法吗?
"The value of $created will be true if a new record was created
(rather than an update)."
因此返回 $created 并不是正确的选择,它只是为了帮助您编码 :)。
您不必return任何操作,因为数据已经保存,您只需在此函数中修改即可。
记住回调方法是在行为函数之后触发的!
GL
我正在使用 afterSave() 回调来清除我的模型的一些缓存查询。我检查了文档,但没有说明 TRUE/FALSE 是否应该 returned。对于 beforeSave(),您需要 return TRUE/FALSE。回调 header 如下所示:
afterSave(boolean $created, array $options = array())
我最初的想法是我应该 return $created 但它只是不清楚。对此有什么想法吗?
"The value of $created will be true if a new record was created (rather than an update)."
因此返回 $created 并不是正确的选择,它只是为了帮助您编码 :)。
您不必return任何操作,因为数据已经保存,您只需在此函数中修改即可。
记住回调方法是在行为函数之后触发的!
GL