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


PHP CakeTime::toServer方法代码示例

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


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

示例1: convertIso8601ToSqlDatetime

 /**
  * Convert Datetime String from Iso8601 to Sql Format
  * 
  * @author	Everton Yoshitani <everton@wizehive.com>
  * @since	1.0
  * @param	array	$data
  * @return	array
  */
 public function convertIso8601ToSqlDatetime($data = array())
 {
     foreach ($data as $attribute => $value) {
         if (empty($this->_attributes['original'][$attribute]) || is_array($value) || empty($this->_attributes['original'][$attribute]['type']) || $this->_attributes['original'][$attribute]['type'] !== 'datetime') {
             continue;
         }
         $field = $this->_attributes['original'][$attribute];
         $data[$attribute] = CakeTime::toServer($value, $this->_timezone);
     }
     return $data;
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:19,代码来源:ApiInputDataComponent.php

示例2: rendersConditions

 /**
  * Parse Request Query Parameters to Model Conditions
  *
  * @author 	Everton Yoshitani <everton@wizehive.com>
  * @since 	1.0
  * @return 	array
  */
 public function rendersConditions()
 {
     $field_map = $this->_field_map;
     $this->withFieldMap();
     if (empty($field_map)) {
         return array();
     }
     $query = $this->_passed_params;
     $this->withPassedParams();
     if (empty($query)) {
         $query = $this->Controller->request->query;
     }
     if (empty($query)) {
         return array();
     }
     $model = $this->_model;
     $this->onModel();
     if (empty($model)) {
         $model = $this->Controller->modelClass;
     }
     if (!isset($this->{$model})) {
         $this->{$model} = ClassRegistry::init($model);
     }
     $timezone = $this->getTimezone();
     $attributes = $this->{$model}->attributes();
     $conditions = array();
     foreach ($query as $condition => $value) {
         $attribute = $condition;
         $prefix_match = null;
         $prefixes = $this->prefixes();
         foreach ($prefixes as $prefix) {
             $match = $prefix . '-';
             $strlen = strlen($match);
             if (!strncmp($condition, $match, $strlen)) {
                 $prefix_match = $prefix;
                 $attribute = substr($condition, $strlen);
             }
         }
         $field = array_search($attribute, $field_map);
         if (empty($field)) {
             continue;
         }
         if (in_array($field, $this->_reserved_query_parameters)) {
             continue;
         }
         if (empty($prefix_match)) {
             if (strstr($value, '|') && strpos($value, '"') !== 0) {
                 $value = explode('|', $value);
             } elseif (strpos($value, '"') === 0 && strrpos($value, '"') === strlen($value) - 1) {
                 $value = substr($value, 1, -1);
             }
         }
         $is_value_array = is_array($value);
         if (!$is_value_array) {
             $value = array($value);
         }
         if ($attributes[$attribute]['query'] === false) {
             continue;
         }
         $type = null;
         if (!empty($attributes[$attribute]['type'])) {
             $type = $attributes[$attribute]['type'];
         }
         if ($type === 'datetime') {
             foreach ($value as $value_key => $value_val) {
                 $value[$value_key] = CakeTime::toServer($value_val, $timezone);
             }
         }
         $field_options = $this->{$model}->getOptions($field);
         if (!empty($field_options)) {
             foreach ($value as $key => $individual_value) {
                 if (in_array($individual_value, $field_options)) {
                     $value[$key] = array_search($individual_value, $field_options);
                 }
             }
         }
         if (!$is_value_array) {
             $value = $value[0];
         }
         switch ($prefix_match) {
             case 'not':
                 $value = $this->onModel($model)->onField($field)->withValue($value)->returnsFormattedValue();
                 if ($value === 'null') {
                     $conditions["{$model}.{$field} !="] = NULL;
                 } else {
                     $conditions[] = array('OR' => array("{$model}.{$field} !=" => $value, "{$model}.{$field}" => NULL));
                 }
                 break;
             case 'min':
                 $value = $this->onModel($model)->onField($field)->withValue($value)->returnsFormattedValue();
                 $conditions["{$model}.{$field} >="] = $value;
                 break;
             case 'max':
//.........这里部分代码省略.........
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:101,代码来源:ApiQueryComponent.php

示例3: testConvertIso8601ToSqlDatetime

 /**
  * Test Convert Iso8601 To Sql Datetime - Results
  *
  * @author  Everton Yoshitani <everton@wizehive.com>
  * @author	Anthony Putignano <anthony@wizehive.com>
  * @since	1.0
  * @return  void
  */
 public function testConvertIso8601ToSqlDatetime()
 {
     $data = array('id' => 1, 'name' => 'Name', 'tags' => array('one', 'two', 'three'), 'lastView.tricky' => '2013-03-05T13:56:02+0900', 'created' => '2013-03-01T13:00:00+0000');
     $this->InputData->_timezone = 'UTC';
     $this->InputData->_ModelObject = $this->getMock('ApiInputDataComponentThing');
     $this->InputData->_model = $this->test_model;
     $this->InputData->_attributes['original'] = array('id' => array('type' => 'integer'), 'name' => array('type' => 'text'), 'tag' => array('type' => 'text'), 'lastView.tricky' => array('field' => 'last_view.tricky', 'type' => 'datetime'), 'created' => array('type' => 'datetime'));
     $result = $this->InputData->convertIso8601ToSqlDatetime($data);
     $expected = $data;
     $expected['lastView.tricky'] = CakeTime::toServer($expected['lastView.tricky'], 'UTC');
     $expected['created'] = CakeTime::toServer($expected['created'], 'UTC');
     $this->assertEquals($expected, $result);
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:21,代码来源:ApiInputDataComponentTest.php


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