Welcome Guest, Not a member yet? Register   Sign In
get_instance() and MY_Exceptions
#1

[eluser]AtlantixMedia[/eluser]
Hello,

can anyone tell me what's wrong with this?

MY_Exceptions in application/libraries

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Exceptions extends CI_Exceptions {


    //==========================================================    
    function MY_Exceptions()
    //==========================================================    
    {
        parent::CI_Exceptions();
    }

    //==========================================================
    function Log_To_Db($type = '', $severity = '', $message = '', $filepath = '', $line = '')
    //==========================================================    
    {    
        $CI =& get_instance();
        if ($CI->config->item('EnableErrorLogging') == 1)
        {
            $CI->load->model('Admin_Model');
            $CI->Admin_Model->LogError_Q($type, $severity, $message, $filepath, $line);
        }

    }
    
}

I keep getting an error pointing to $CI =& get_instance();

Fatal error: Call to undefined function get_instance() in /home/content/../../../system/application/libraries/MY_Exceptions.php on line 86

thanks
#2

[eluser]Tom Glover[/eluser]
Remove it, as it is not required in MY_ class's as when it is there it is trying to call the CI core, even though that is already called in the main lib.
#3

[eluser]AtlantixMedia[/eluser]
actually I found what's wrong with it: that happens when I try to save to a db table a 404 error which cannot be done as that error occurs before any controller get loaded
#4

[eluser]juworld[/eluser]
Good point, how did you work around it?

I want to track the referrals for my 404 pages. I want to know where is the page the user was trying to hit that we don't have.




Theme © iAndrew 2016 - Forum software by © MyBB