Changeset 484 for trunk/lib/DB.inc.php
- Timestamp:
- Jul 30, 2014 10:43:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/DB.inc.php
r479 r484 33 33 34 34 // A place to keep an object instance for the singleton pattern. 35 pr ivatestatic $instance = null;35 protected static $instance = null; 36 36 37 37 // If $db->connect has successfully opened a db connection. 38 pr ivate$_connected = false;38 protected $_connected = false; 39 39 40 40 // Database handle. … … 42 42 43 43 // Count how many queries run during the whole instance. 44 pr ivate$_query_count = 0;44 protected $_query_count = 0; 45 45 46 46 // Hash of DB parameters. 47 pr ivate$_params = array();47 protected $_params = array(); 48 48 49 49 // Default parameters. 50 pr ivate$_param_defaults = array(50 protected $_param_defaults = array( 51 51 52 52 // DB passwords should be set as apache environment variables in httpd.conf, readable only by root. … … 73 73 74 74 // Caches. 75 pr ivate$existing_tables;76 pr ivate$table_columns;75 protected $existing_tables; 76 protected $table_columns; 77 77 78 78 /** … … 147 147 148 148 // 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. 149 150 if ($this->dbh = @mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) { 150 151 // Select database … … 222 223 * @since 15 Jan 2007 15:59:00 223 224 */ 224 pr ivatefunction _fail()225 protected function _fail() 225 226 { 226 227 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 } 229 233 die; 230 234 } else { … … 318 322 $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__); 319 323 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 } 321 327 } 322 328 // Die if db_die_on_failure = true, or just continue without connection … … 355 361 return true; 356 362 } 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__); 358 364 return false; 359 365 }
Note: See TracChangeset
for help on using the changeset viewer.