Пример #1
0
 /**
  * Connect to Database
  * @method connnectDatabase
  * @return void
  */
 protected function connect_database($dsn, $user = '', $passwd = '')
 {
     require_once CX_BASE_DIR . 'classes' . DS . 'cx' . DS . 'database' . DS . 'db.php';
     $this->database = new cx_db($dsn, $user, $passwd);
     if (!is_object($this->database)) {
         cx_email_error('The Database is DOWN!!!');
         if (defined('CX_LIVE') && CX_LIVE === true) {
             cx_global_error_handler();
             exit;
         } else {
             echo "The Database is down";
             exit;
         }
     }
     if (is_object($this->database)) {
         $this->database->error_callback_set('cx_global_error_handler');
         $this->database->init_db();
     } else {
         throw new \Exception('Unable to connect to database!!');
     }
 }
Пример #2
0
 private function debug()
 {
     $error = array("Error" => $this->error);
     if (!empty($this->sql)) {
         $error["SQL Statement"] = $this->sql;
     }
     if (!empty($this->bind)) {
         $error["Bind Parameters"] = trim(print_r($this->bind, true));
     }
     $backtrace = debug_backtrace();
     if (!empty($backtrace)) {
         foreach ($backtrace as $info) {
             if ($info["file"] != __FILE__) {
                 $error["Backtrace"] = $info["file"] . " at line " . $info["line"];
             }
         }
     }
     $msg = "SQL Error\n" . str_repeat("-", 50);
     foreach ($error as $key => $val) {
         $msg .= "\n\n{$key}:\n{$val}";
     }
     if (defined('CX_LIVE') && CX_LIVE === false) {
         echo "<pre>";
         echo $msg;
         echo "</pre>";
         exit;
     } else {
         cx_email_error($msg);
         if (!empty($this->error_callback_function)) {
             $func = $this->error_callback_function;
             $func($msg);
             exit;
         }
     }
 }
Пример #3
0
function cx_custom_error_checker()
{
    $a_errors = error_get_last();
    if (is_array($a_errors)) {
        if (defined('CX_LIVE') && CX_LIVE === true) {
            $msg = "Error: {$a_errors['message']} File:{$a_errors['file']} Line:{$a_errors['line']}.";
            cx_email_error($msg);
            cx_global_error_handler();
        } else {
            echo '<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">';
            echo '<base href="' . CX_BASE_REF . '"/>';
            echo '<link rel="stylesheet" href="../cx/assets/bootstrap/css/bootstrap.min.css" type="text/css" media="all" />';
            echo "</head>\r\n<body>\r\n";
            echo '<div class="alert alert-danger">';
            echo "{$a_errors['message']}, in file: {$a_errors['file']}, on line #{$a_errors['line']}.";
            echo '</div>';
            echo "</body>\r\n</html>";
        }
    }
}