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 996121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:49:43+00:00 2026-05-16T06:49:43+00:00

Ok so again my question is kind of a best practices/techniques question so I’m

  • 0

Ok so again my question is kind of a best practices/techniques question so I’m assuming there will be a few different ways to handle this.

So, to what degree should I factor in error handling? As an example, say I havee a basic function in my model which retrieves a customers record ie

function get_customer($customer_id) {

    $this->where('id',$customer_id);
    $query = $this->db->get('customers');

    return $query->result();

}

Should I put in something to check whether the parameter $customer_id, exists and is the correct type? or does it depend on the logic of the application? For instance, in some cases this function would never be called unless $customer_id is set and that might be checked in the controller, but is it best practice to include the error checking here as well?

Also, should I use something like try/catch and throw an exception or can it just be as simple as if ($customer_id!=”) etc ?

  • 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-16T06:49:44+00:00Added an answer on May 16, 2026 at 6:49 am

    You are using the above function from a controller right? The best place to make sure that the variable $customer_id is of correct type and contains what you expect, you need to check it from within the controller before sending it to the model. The controller puts you in a position to show the error by redirecting or whatever.

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

Sidebar

Related Questions

Sorry to ask this kind of question once again but I could not solve
Why the same question again This question has been asked around 100 times on
I regret to ask this question again. I am trying to implement autocomplete on
Sorry to ask this question again but I tried several solutions on stackoverflow and
Before you all get pissy about me posting this question again, let me explain
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
I am again posting the same question. Please help me in this problem. Here
I've kind of asked this question earlier so sorry for asking a bit similar
This question is kind of anecdotical but still interesting to me; I was wondering
I know that this type of question has been asked over and over again,

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.