includes/dbal.php
changeset 809 ae4ef502f742
parent 801 eb8b23f11744
child 812 68060328e9c6
equal deleted inserted replaced
808:97cd1a3229d0 809:ae4ef502f742
    39 class mysql {
    39 class mysql {
    40   var $num_queries, $query_backtrace, $query_times, $query_sources, $latest_result, $latest_query, $_conn, $sql_stack_fields, $sql_stack_values, $debug;
    40   var $num_queries, $query_backtrace, $query_times, $query_sources, $latest_result, $latest_query, $_conn, $sql_stack_fields, $sql_stack_values, $debug;
    41   var $row = array();
    41   var $row = array();
    42 	var $rowset = array();
    42 	var $rowset = array();
    43   var $errhandler;
    43   var $errhandler;
       
    44   var $dbms_name = 'MySQL';
    44   
    45   
    45   function enable_errorhandler()
    46   function enable_errorhandler()
    46   {
    47   {
    47     if ( !defined('ENANO_DEBUG') )
    48     if ( !defined('ENANO_DEBUG') )
    48       return true;
    49       return true;
   103     exit;
   104     exit;
   104   }
   105   }
   105   
   106   
   106   function die_json($loc = false)
   107   function die_json($loc = false)
   107   {
   108   {
   108     $e = addslashes(htmlspecialchars(mysql_error()));
   109     $e = str_replace("\n", "\\n", addslashes(htmlspecialchars(mysql_error())));
   109     $q = str_replace("\n", "\\n", addslashes($this->latest_query));
   110     $q = str_replace("\n", "\\n", addslashes($this->latest_query));
   110     $loc = ( $loc ) ? addslashes("\n\nDescription or location of error: $loc") : "";
   111     $loc = ( $loc ) ? addslashes("\n\nDescription or location of error: $loc") : "";
   111     $loc .= "\n\nPlease report the full text of this error to the administrator of the site. If you believe that this is a bug with the software, please contact support@enanocms.org.";
   112     $loc .= "\n\nPlease report the full text of this error to the administrator of the site. If you believe that this is a bug with the software, please contact support@enanocms.org.";
   112     $loc = str_replace("\n", "\\n", $loc);
   113     $loc = str_replace("\n", "\\n", $loc);
   113     $t = "{\"mode\":\"error\",\"error\":\"An error occurred during database query.\\nQuery was:\\n  $q\\n\\nError returned by MySQL: $e$loc\"}";
   114     $t = "{\"mode\":\"error\",\"error\":\"An error occurred during database query.\\nQuery was:\\n  $q\\n\\nError returned by MySQL: $e$loc\"}";
   769 class postgresql {
   770 class postgresql {
   770   var $num_queries, $query_backtrace, $query_times, $query_sources, $latest_result, $latest_query, $_conn, $sql_stack_fields, $sql_stack_values, $debug;
   771   var $num_queries, $query_backtrace, $query_times, $query_sources, $latest_result, $latest_query, $_conn, $sql_stack_fields, $sql_stack_values, $debug;
   771   var $row = array();
   772   var $row = array();
   772 	var $rowset = array();
   773 	var $rowset = array();
   773   var $errhandler;
   774   var $errhandler;
       
   775   var $dbms_name = 'PostgreSQL';
   774   
   776   
   775   function sql_backtrace()
   777   function sql_backtrace()
   776   {
   778   {
   777     return implode("\n-------------------------------------------------------------------\n", $this->query_backtrace);
   779     return implode("\n-------------------------------------------------------------------\n", $this->query_backtrace);
   778   }
   780   }
   807     exit;
   809     exit;
   808   }
   810   }
   809   
   811   
   810   function die_json()
   812   function die_json()
   811   {
   813   {
   812     $e = addslashes(htmlspecialchars(pg_last_error()));
   814     $e = str_replace("\n", "\\n", addslashes(htmlspecialchars(pg_last_error())));
   813     $q = addslashes($this->latest_query);
   815     $q = str_replace("\n", "\\n", addslashes($this->latest_query));
   814     $t = "{'mode':'error','error':'An error occurred during database query.\nQuery was:\n  $q\n\nError returned by PostgreSQL: $e'}";
   816     $loc = ( $loc ) ? addslashes("\n\nDescription or location of error: $loc") : "";
       
   817     $loc .= "\n\nPlease report the full text of this error to the administrator of the site. If you believe that this is a bug with the software, please contact support@enanocms.org.";
       
   818     $loc = str_replace("\n", "\\n", $loc);
       
   819     $t = "{\"mode\":\"error\",\"error\":\"An error occurred during database query.\\nQuery was:\\n  $q\\n\\nError returned by MySQL: $e$loc\"}";
   815     die($t);
   820     die($t);
   816   }
   821   }
   817   
   822   
   818   function get_error($t = '') {
   823   function get_error($t = '') {
   819     @header('HTTP/1.1 500 Internal Server Error');
   824     @header('HTTP/1.1 500 Internal Server Error');