當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。