What are Hooks in CakePHP?

Sharad Jaiswal
Sharad Jaiswal

Posted On: Feb 22, 2018

 

    1 Answer Written

  •  Sharad Jaiswal
    Answered by Priyanka

    Hooks in Cakephp are nothing but the functions that are called prior or after doing any task in the models related to the database. These are the callback functions like after finding data, before saving data, etc. Some example for this method are beforeSave(), afterSave(), beforeFind(), afterFind(), etc.

    Example

    <?php
    class Classname extends AppModel {
        var $name = "Classname";
       public function beforeSave(){
            // your code
        }
       public function afterSave(){
            // your code
        }
    }   
    ?>
    
    

Related Questions

Please Login or Register to leave a response.

Related Questions

Cakephp interview questions

What is CakePHP ?

CakePHP is an open-source free web framework written in PHP scripting Language for rapid web development...

Cakephp interview questions

What is MVC in CakePHP?

MVC stands for the model view controller.MVC is not a design pattern, it is an architectural pattern that describes a way to structure our application and explains the responsibilities and interaction..