I am developing an application in cakephp. In this application I am using saveAll() function at many different places to save multiple records. What is need is to create a callback function which automatically gets called after saveAll() is executed, as I think there is no predefined callback function in cakephp which gets called after saveAll(). I know there is a function afterSave(), which gets called after every save() action. What can be the solution. Any suggestions would really be appreciated. Thank you :)
Asked
Active
Viewed 1,416 times
0
-
I think afertSave() http://book.cakephp.org/1.3/es/view/1053/afterSave function is your best chance. – Lobo Apr 09 '12 at 07:57
-
but the problem is that afterSave() gets called after every single row is saved. So cant use it. – Vineet Apr 09 '12 at 08:04
-
Redefine saveAll function in your model. – Lobo Apr 09 '12 at 08:08
2 Answers
1
public function saveAll($data, $options) {
$return = parent::saveAll($data, $options);
// your callback code here
return $return;
}

deceze
- 510,633
- 85
- 743
- 889
1
You can redefine the saveAll function in your model as follows:
function saveAll($datos=null, $opciones = array()){
parent::saveAll($datos, $opciones);
$this->yourCallBackFunction();
}
function yourCallBackFunction(){
//do something
}
Regards!

Lobo
- 4,001
- 8
- 37
- 67