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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:20:52+00:00 2026-06-13T07:20:52+00:00

I have 3 class name Controller , Loader , Error and Ex_controller . Controller.php

  • 0

I have 3 class name “Controller“,”Loader“,”Error” and “Ex_controller“.

“Controller.php“

class Controller
{
     function __Construct()
     {
           $this->load = Loader::getinstant();
           $this->error = $this->load->class('Error');
     }
}

“Loader.php“

class Loader
{
     function class($class)
     {
           require_once($class);
           return new $class;
     }
}

“Error.php“

class Error
{
     function query($query)
     {
           $res = mysql_query($query)
           if($res)
           {
                  return $res;
           }else{
                  die('Could not execute query: '.mysql_error().'at line '. __LINE__ . 
                       ' in file ' . __FILE__);//does it work?If it doesn't, how to
                                                 make it work?
           }
     }
}

“Ex_controller.php“

class Ex_controller extends Controller
{
     function __Construct()
     {
           parent::__construct();
           $result = $this->error->query('some sql query');//(*)
     }
}

How can I show where the error occur in Ex_controller with (*)?

  • 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-06-13T07:20:54+00:00Added an answer on June 13, 2026 at 7:20 am

    First of all, you should stop using mysql_xxx functions as they’re in the process of deprecating the old API.

    That aside, in this case, it’s probably worthwhile to start using exceptions instead of a plain old die().

    if($res) {
        return $res;
    }else{
        throw new Exception("Could not execute query '$query': " . mysql_error());
    }
    

    Then inside the controller:

    try {
        $result = $this->error->query('some sql query');//(*)
    } catch (Exception $e) {
        die(print_r($e, true)); // do something more useful with the exception though.
    }
    

    When you catch the exception higher up and you would print_r() it, you will see the complete stack trace with files, line numbers and everything.

    Plus, you get the chance to handle the error as well.

    Plus plus, if you would use PDO with exception error handling enabled, you don’t even have to throw exceptions yourself anymore.

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

Sidebar

Related Questions

I'm working with a controller name page.php . This is what I have: class
I have a class like this, public class person { name Name {set; get;}
THIS IS FIXED, I had named my function the same name as my controller,
I have a simple controller named AjaxController, <?php class AjaxController extends Zend_Controller_Action { public
Specifically, does a controller class name have to have the Controller suffix, and can
I have a class Person and a class Name. Name contains two Strings firstName
So i have a class name repository which is just a simple array.Here is
I have style sheet with a class name changebackgroundcolor i want make change in
I have many DIV with the same class name, let save wmplayer. I want
I have a bunch of links with the class name row. What I'm trying

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.