Changeset 484 for trunk/lib/DB.inc.php


Ignore:
Timestamp:
Jul 30, 2014 10:43:49 PM (10 years ago)
Author:
anonymous
Message:

Changed private methods and properties to protected. A few minor bug fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/DB.inc.php

    r479 r484  
    3333
    3434    // A place to keep an object instance for the singleton pattern.
    35     private static $instance = null;
     35    protected static $instance = null;
    3636
    3737    // If $db->connect has successfully opened a db connection.
    38     private $_connected = false;
     38    protected $_connected = false;
    3939
    4040    // Database handle.
     
    4242
    4343    // Count how many queries run during the whole instance.
    44     private $_query_count = 0;
     44    protected $_query_count = 0;
    4545
    4646    // Hash of DB parameters.
    47     private $_params = array();
     47    protected $_params = array();
    4848
    4949    // Default parameters.
    50     private $_param_defaults = array(
     50    protected $_param_defaults = array(
    5151
    5252        // DB passwords should be set as apache environment variables in httpd.conf, readable only by root.
     
    7373
    7474    // Caches.
    75     private $existing_tables;
    76     private $table_columns;
     75    protected $existing_tables;
     76    protected $table_columns;
    7777
    7878    /**
     
    147147
    148148        // Connect to database. Always create a new link to the server.
     149        // Connection errors are surpressed so we can do our own error management below.
    149150        if ($this->dbh = @mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {
    150151            // Select database
     
    222223    * @since    15 Jan 2007 15:59:00
    223224    */
    224     private function _fail()
     225    protected function _fail()
    225226    {
    226227        if ($this->getParam('db_die_on_failure')) {
    227             header(' ', true, 503);
    228             echo _("This page is temporarily unavailable. Please try again in a few minutes.");
     228            if (!defined('_CLI')) {
     229                // For http requests, send a Service Unavailable header.
     230                header(' ', true, 503);
     231                echo _("This page is temporarily unavailable. Please try again in a few minutes.");
     232            }
    229233            die;
    230234        } else {
     
    318322            $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
    319323            if ($this->getParam('db_debug')) {
    320                 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
     324                if (!defined('_CLI')) {
     325                    echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
     326                }
    321327            }
    322328            // Die if db_die_on_failure = true, or just continue without connection
     
    355361            return true;
    356362        } else {
    357             $app->logMsg(sprintf('Nonexistent DB table: %s.%s', $this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
     363            $app->logMsg(sprintf('Nonexistent DB table: %s.%s', $this->getParam('db_name'), $table), LOG_INFO, __FILE__, __LINE__);
    358364            return false;
    359365        }
Note: See TracChangeset for help on using the changeset viewer.