private function _setDatabaseOptions()
 {
     if (is_object(Config::getInstance()->getValue('database'))) {
         if (Config::getInstance()->getValue('database')->hasValue('charset')) {
             $lCharset = Config::getInstance()->getValue('database')->getValue('charset');
         } else {
             trigger_error('Warning undefined charset database. By default charset is set to \'utf8\' ');
             $lCharset = 'utf8';
         }
         if (Config::getInstance()->getValue('database')->hasValue('timezone')) {
             $lTimezone = Config::getInstance()->getValue('database')->getValue('timezone');
         } else {
             trigger_error('Warning undefined timezone database. By default charset is set to \'utf8\' ');
             $lTimezone = 'UTC';
         }
     } else {
         trigger_error('Warning undefined database options connections');
         $lCharset = 'utf8';
         $lTimezone = 'UTC';
     }
     $lDate = new \DateTime('now', new \DateTimeZone($lTimezone));
     $lTotalOffsetSeconds = $lDate->getOffset();
     $lOffsetOperator = $lTotalOffsetSeconds >= 0 ? '+' : '-';
     $lOffsetHours = floor(abs($lTotalOffsetSeconds) / 3600);
     $lOffsetMinutes = floor(abs($lTotalOffsetSeconds) % 3600 / 60);
     $lOffset = $lOffsetOperator . $lOffsetHours . ':' . $lOffsetMinutes;
     $this->mDbHandle->exec("SET NAMES {$lCharset};");
     $this->mDbHandle->exec("SET time_zone = '{$lOffset}';");
 }
 private function __construct()
 {
     self::$_instance = $this;
     $this->_registerSimpleModelClasses();
     ManifestParser::registerComplexModels(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'manifestCollection' . DIRECTORY_SEPARATOR . 'manifest' . DIRECTORY_SEPARATOR . 'manifestList.json', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'manifestCollection' . DIRECTORY_SEPARATOR . 'serialization' . DIRECTORY_SEPARATOR . 'serializationList.json', $this->mInstanceModels);
     ManifestParser::registerComplexModels(Config::getInstance()->getValue('manifestList'), Config::getInstance()->getValue('serializationList'), $this->mInstanceModels);
 }
Esempio n. 3
0
 public function _fillObjectFromSqlDatabase(Object $pObject, $pRow, $pDateTimeZone, $pLocalObjectCollection, $pAddUnloadValues = true)
 {
     $lDatabaseTimezone = Config::getInstance()->getValue('database')->getValue('timezone');
     $lDefaultTimeZone = false;
     if (date_default_timezone_get() != $lDatabaseTimezone) {
         $lDefaultTimeZone = date_default_timezone_get();
         date_default_timezone_set($lDatabaseTimezone);
     }
     foreach ($this->getProperties() as $lPropertyName => $lProperty) {
         if (array_key_exists($lProperty->getSerializationName(), $pRow)) {
             if (is_null($pRow[$lProperty->getSerializationName()])) {
                 continue;
             }
             $pObject->setValue($lPropertyName, $lProperty->getModel()->_fromSqlColumn($pRow[$lProperty->getSerializationName()], $pDateTimeZone, $pLocalObjectCollection));
         } else {
             if ($pAddUnloadValues && $lProperty instanceof ForeignProperty && !is_null($lProperty->hasSqlTableUnit())) {
                 $pObject->initValue($lPropertyName, false);
             }
         }
     }
     if ($lDefaultTimeZone) {
         date_default_timezone_set($lDefaultTimeZone);
     }
 }
 public static function getDatabaseConnectionTimeZone()
 {
     return is_object(Config::getInstance()->getValue('database')) ? Config::getInstance()->getValue('database')->hasValue('timezone') ? Config::getInstance()->getValue('database')->getValue('timezone') : 'UTC' : 'UTC';
 }