What are Hooks in CakePHP?

  • Sharad Jaiswal
  • 22nd Feb, 2018

1 answer(s) :

  •   Reply
    img

    Priyanka

    13th Feb, 2020
    "

    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
        }
    }   
    ?>
    
    

Post your Answer :

Valid name is required.

Valid name is required.

Valid email id is required.