当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseConnection::getDateTimeFormats方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Database\DatabaseConnection::getDateTimeFormats方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::getDateTimeFormats方法的具体用法?PHP DatabaseConnection::getDateTimeFormats怎么用?PHP DatabaseConnection::getDateTimeFormats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Database\DatabaseConnection的用法示例。


在下文中一共展示了DatabaseConnection::getDateTimeFormats方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * PlanningUtility constructor.
  */
 public function __construct()
 {
     $this->objM = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
     $this->sessionRepository = $this->objM->get(AnySessionRepository::class);
     $this->db = $GLOBALS['TYPO3_DB'];
     $dateTimeFormats = $this->db->getDateTimeFormats('tx_sessions_domain_model_session');
     $this->dbDateTimeFormat = $dateTimeFormats['datetime']['format'];
 }
开发者ID:t3dd,项目名称:T3DD16.Backend,代码行数:11,代码来源:PlanningUtility.php

示例2: addDataConvertsDateTimeStringToTimestamp

 /**
  * @test
  */
 public function addDataConvertsDateTimeStringToTimestamp()
 {
     $oldTimezone = date_default_timezone_get();
     date_default_timezone_set('UTC');
     $input = ['tableName' => 'aTable', 'processedTca' => ['columns' => ['aField' => ['config' => ['dbType' => 'datetime']]]], 'databaseRow' => ['aField' => '2015-07-27 15:25:32']];
     $expected = $input;
     $expected['databaseRow']['aField'] = 1438010732;
     // 27.07.2015 15:25:32 UTC
     $this->dbProphecy->getDateTimeFormats(Argument::cetera())->willReturn($this->dateFormats);
     $this->assertEquals($expected, $this->subject->addData($input));
     date_default_timezone_set($oldTimezone);
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:15,代码来源:DatabaseRowDateTimeFieldsTest.php

示例3: checkValueForInput

 /**
  * Evaluate "input" type values.
  *
  * @param string $value The value to set.
  * @param array $tcaFieldConf Field configuration from TCA
  * @param string $table Table name
  * @param int $id UID of record
  * @param int $realPid The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
  * @param string $field Field name
  * @return array $res The result array. The processed value (if any!) is set in the "value" key.
  */
 protected function checkValueForInput($value, $tcaFieldConf, $table, $id, $realPid, $field)
 {
     // Handle native date/time fields
     $isDateOrDateTimeField = false;
     $format = '';
     $emptyValue = '';
     if (isset($tcaFieldConf['dbType']) && ($tcaFieldConf['dbType'] === 'date' || $tcaFieldConf['dbType'] === 'datetime')) {
         $isDateOrDateTimeField = true;
         $dateTimeFormats = $this->databaseConnection->getDateTimeFormats($table);
         // Convert the date/time into a timestamp for the sake of the checks
         $emptyValue = $dateTimeFormats[$tcaFieldConf['dbType']]['empty'];
         $format = $dateTimeFormats[$tcaFieldConf['dbType']]['format'];
         // At this point in the processing, the timestamps are still based on UTC
         $timeZone = new \DateTimeZone('UTC');
         $dateTime = \DateTime::createFromFormat('!' . $format, $value, $timeZone);
         $value = $value === $emptyValue ? 0 : $dateTime->getTimestamp();
     }
     // Secures the string-length to be less than max.
     if ((int) $tcaFieldConf['max'] > 0) {
         $value = $GLOBALS['LANG']->csConvObj->substr($GLOBALS['LANG']->charSet, (string) $value, 0, (int) $tcaFieldConf['max']);
     }
     // Checking range of value:
     // @todo: The "checkbox" option was removed for type=input, this check could be probably relaxed?
     if ($tcaFieldConf['range'] && $value != $tcaFieldConf['checkbox'] && (int) $value !== (int) $tcaFieldConf['default']) {
         if (isset($tcaFieldConf['range']['upper']) && (int) $value > (int) $tcaFieldConf['range']['upper']) {
             $value = $tcaFieldConf['range']['upper'];
         }
         if (isset($tcaFieldConf['range']['lower']) && (int) $value < (int) $tcaFieldConf['range']['lower']) {
             $value = $tcaFieldConf['range']['lower'];
         }
     }
     if (empty($tcaFieldConf['eval'])) {
         $res = array('value' => $value);
     } else {
         // Process evaluation settings:
         $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']);
         if ($this->runtimeCache->has($cacheId)) {
             $evalCodesArray = $this->runtimeCache->get($cacheId);
         } else {
             $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true);
             $this->runtimeCache->set($cacheId, $evalCodesArray);
         }
         $res = $this->checkValue_input_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']);
         // Process UNIQUE settings:
         // Field is NOT set for flexForms - which also means that uniqueInPid and unique is NOT available for flexForm fields! Also getUnique should not be done for versioning and if PID is -1 ($realPid<0) then versioning is happening...
         if ($field && $realPid >= 0 && !empty($res['value'])) {
             if (in_array('uniqueInPid', $evalCodesArray, true)) {
                 $res['value'] = $this->getUnique($table, $field, $res['value'], $id, $realPid);
             }
             if ($res['value'] && in_array('unique', $evalCodesArray, true)) {
                 $res['value'] = $this->getUnique($table, $field, $res['value'], $id);
             }
         }
     }
     // Handle native date/time fields
     if ($isDateOrDateTimeField) {
         // Convert the timestamp back to a date/time
         $res['value'] = $res['value'] ? date($format, $res['value']) : $emptyValue;
     }
     return $res;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:72,代码来源:DataHandler.php


注:本文中的TYPO3\CMS\Core\Database\DatabaseConnection::getDateTimeFormats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。