Changeset 660 for trunk/lib/DB.inc.php
- Timestamp:
- Jan 28, 2019 10:51:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/DB.inc.php
r659 r660 69 69 'zero_date' => '0000-00-00', 70 70 'infinity_date' => '9999-12-31', 71 72 // Timezone for MySQL. 73 'timezone' => 'UTC', 71 74 ); 72 75 … … 189 192 $this->_connected = true; 190 193 194 $init_sql = array(); 195 191 196 // Tell MySQL what character set we're using. Available only on MySQL versions > 4.01.01. 192 197 if ('' != $app->getParam('character_set') && isset($this->mysql_character_sets[mb_strtolower($app->getParam('character_set'))])) { 193 $ this->query("/*!40101 SET NAMES '" . $this->mysql_character_sets[mb_strtolower($app->getParam('character_set'))] . "' */");198 $init_sql[] = sprintf("SET NAMES '%s'", $this->mysql_character_sets[mb_strtolower($app->getParam('character_set'))]); 194 199 } else { 195 200 $app->logMsg(sprintf('%s is not a known character_set.', $app->getParam('character_set')), LOG_ERR, __FILE__, __LINE__); … … 201 206 } 202 207 203 // Set timezone. 204 $tz = date_default_timezone_get(); 205 // Check that PHP is configured with a valid timezone name, e.g., "UTC" or "America/Mexico_City" or "-6:00". 206 if ($app->getParam('timezone') && $app->getParam('timezone') == $tz && preg_match('!^([A-Z_/-]{3,}|[-+\d:]+)$!i', $tz)) { 208 // Set MySQL session timezone. 209 if ($this->getParam('timezone')) { 207 210 // https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html 208 $this->query(sprintf("SET SESSION time_zone = '%s'", $tz)); 211 $init_sql[] = sprintf("SET time_zone = '%s'", $this->getParam('timezone')); 212 } 213 214 // Run init query, if set. 215 if (!empty($init_sql)) { 216 $this->query(join('; ', $init_sql)); 209 217 } 210 218 … … 506 514 } 507 515 508 509 516 } // End. 510 517
Note: See TracChangeset
for help on using the changeset viewer.