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

  • SEARCH
  • Home
  • 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 6974279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:13:00+00:00 2026-05-27T17:13:00+00:00

The following function in MerryParent model returns $merry_parent_id or empty string if it is

  • 0

The following function in MerryParent model returns $merry_parent_id or empty string if it is not able to find any. If it is going to return an empty string, i want to stop that and display an error message in the model itself instead of creating an if then else stmt in controller and displaying the error message there. How can I do that?

I don’t know on how to display error msgs in model function. In controller I know that I can use $this->Session->setFlash(‘my error msg’). But that doesn’t work here.

By the way, i’m trying to abide by ‘fat model thin controller approach’. 🙂

class MerryParent extends AppModel{
    //relationships are displayed here
    //form field validations are displayed here

    function getMerryParentId($email){
        $merry_parent_id=$this->field('id',array('MerryParent.email'=>$email));
        return $merry_parent_id;
                /*instead as return $merry_parent_id, I want
                if ($merry_parent_id!='')
                   return $merry_parent_id;
                else
                   //display error message here. 
    }
}

thank you.

  • 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-27T17:13:01+00:00Added an answer on May 27, 2026 at 5:13 pm

    You shouldn’t be displaying errors via the model. If you want to display something just for testing purposes, you can debug() it in the model…etc, but in general, you should use the normal MVC structure, and use the model to retrieve the data, use the controller to process it, and the view to display it.

    The “Fat model / Skinny controller” thing is great to follow as a guideline, but when you follow it too far and stop following the more-important MVC structure, it’s not a good thing. It’s not meant to be “Fat model / Empty controller”. 🙂

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

Sidebar

Related Questions

I have the following function, it will always return True. Any ideas why and
The following function is trying to find the nth to last element of a
I have the following function: CREATE FUNCTION fGetTransactionStatusLog ( @TransactionID int ) RETURNS varchar(8000)
Take the following function: DataTable go() { return someTableAdapter.getSomeData(); } When I set a
The following function returns a type mismatch. I don't understand, as I paid attention
the following function does not work as I thought it should have. For some
The following function out-puts an array and html. I don't want to have <li><a
I have the following function to return a clean path for a script. function
The following function works perfectly: protected void SendWebMailMessage(string DisplayName, string From, string ReplyTo, string
The following function does not produce an alert when I click on the 'overview_table_header'

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.