Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6639683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:34:57+00:00 2026-05-25T23:34:57+00:00

In my cakephp project, I use afterSave() method of a model class. In this

  • 0

In my cakephp project, I use afterSave() method of a model class. In this method, I want to call another method that is located in app_controller file.

class MyModel extends AppModel {

        var $name = 'MyModel';

        function afterSave($created) {

            $this->MyController->updateData();          
        }

}

Here updateData() is located in app_controller file, which is extended by MyController controller.

The above code does not work, so how can i actually call updateData() in this case..

Please guide.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:34:58+00:00Added an answer on May 25, 2026 at 11:34 pm

    This is strongly NOT recommended but it can be done anyway… You should try as deizel says and move that method to AppModel or any other particular model…

    you may use this function

    App::import() check the book here to see how to use it

    in your example:

    class MyModel extends AppModel {
    
            var $name = 'MyModel';
    
            function afterSave($created) {
                App::import('Controller', 'My');
                $something = new MyController;
                $something->updateData();          
            }
    
    }
    

    This is the correct way to load a class inside another place where it shouldn’t be… Still you may use include or required and create an instance of the class since this is php.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've started a php project, it will use cakePhp. I saw that cakePhp has
I have recently been assigned a CSS & design project that's in a CakePHP
CakePHP Newbie :) I am having trouble accessing another controller and passing that data
I am starting to use cakePHP for the first time with a hobby project.
Let me preface by saying this is the first live cakephp project for me.
I am working on a CakePHP project that has a database populated from multiple
I'm trying to use a Microsoft Access database for a demo project that I'm
When I try to run my project (made with cakephp framework), I receive this
I am using spark_plug in my cakephp project and I am having this error
I am trying to use jquery validator in a cakephp project.There is probem with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.