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


PHP MatchaModel::__getFieldProperties方法代码示例

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


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

示例1: parseValues

 /**
  * function parseValues($data):
  * Parse the data and if some values met the type correct them.
  *
  * @param $data
  *
  * @return array
  */
 private function parseValues($data)
 {
     $this->serializedFields = [];
     $record = [];
     $columns = array_keys($data);
     $values = array_values($data);
     foreach ($columns as $index => $column) {
         if (!in_array($column, $this->fields)) {
             unset($columns[$index], $values[$index]);
         }
     }
     foreach ($columns as $col) {
         $properties = (array) MatchaModel::__getFieldProperties($col, $this->model);
         // Check if the type property is set
         // but if the dataType is also defined
         // make use the dataType property (more database oriented)
         // if either type and dataType are defined auto set string
         if (isset($properties['type'])) {
             $type = $properties['type'];
         } elseif (isset($properties['dataType'])) {
             $type = $properties['dataType'];
         } else {
             $type = 'string';
         }
         // Don't parse the value (skip it) if...
         // $properties['store'] is set and is not true OR
         // $properties['persist'] is set and is not true OR
         if ((!isset($properties['store']) || $properties['store']) && (!isset($properties['persist']) || $properties['persist'])) {
             if ($this->encryptedFields !== false && in_array($col, $this->encryptedFields)) {
                 $data[$col] = $this->dataEncrypt($data[$col]);
             } else {
                 if ($type == 'string' && is_string($data[$col])) {
                     $data[$col] = html_entity_decode($data[$col]);
                 } elseif ($type == 'date') {
                     if ($data[$col] === '') {
                         $data[$col] = '0000-00-00';
                     }
                     //$data[$col] = ($data[$col] == '' || is_null($data[$col]) ? '0000-00-00' : $data[$col]);
                 } elseif ($type == 'array') {
                     if ($data[$col] == '') {
                         $data[$col] = null;
                     } else {
                         $this->serializedFields[$col] = $data[$col];
                         $data[$col] = serialize($data[$col]);
                     }
                 }
             }
             /**
              * Do not trim bool, null, objects, or arrays values
              */
             if ($this->autoTrim && ($type != 'bool' && $type != 'int' && $data[$col] != null && !is_object($data[$col]) && !is_array($data[$col]))) {
                 $record[$col] = trim($data[$col]);
             } else {
                 $record[$col] = $data[$col];
             }
         }
     }
     return $record;
 }
开发者ID:ameenalvi,项目名称:gaiaehr,代码行数:67,代码来源:MatchaCUP.php

示例2: parseValues

 /**
  * function parseValues($data):
  * Parse the data and if some values met the type correct them.
  *
  * @param $data
  *
  * @return array
  */
 private function parseValues($data)
 {
     $this->serializedFields = [];
     $record = [];
     $columns = array_keys($data);
     $values = array_values($data);
     foreach ($columns as $index => $column) {
         if (!in_array($column, $this->fields)) {
             unset($columns[$index], $values[$index]);
         }
     }
     foreach ($columns as $col) {
         $properties = (array) MatchaModel::__getFieldProperties($col, $this->model);
         /**
          * Don't parse the value (skip it) if...
          * $properties['store'] is set and is not true OR
          * $properties['persist'] is set and is not true OR
          */
         if ((!isset($properties['store']) || $properties['store']) && (!isset($properties['persist']) || $properties['persist'])) {
             $type = $properties['type'];
             if ($this->encryptedFields !== false && in_array($col, $this->encryptedFields)) {
                 $data[$col] = $this->dataEncrypt($data[$col]);
             } else {
                 if ($type == 'string' && is_string($data[$col])) {
                     $data[$col] = html_entity_decode($data[$col]);
                 } elseif ($type == 'date') {
                     if ($data[$col] === '') {
                         $data[$col] = '0000-00-00';
                     }
                     //						$data[$col] = ($data[$col] == '' || is_null($data[$col]) ? '0000-00-00' : $data[$col]);
                 } elseif ($type == 'array') {
                     if ($data[$col] == '') {
                         $data[$col] = null;
                     } else {
                         $this->serializedFields[$col] = $data[$col];
                         $data[$col] = serialize($data[$col]);
                     }
                 }
             }
             /**
              * do not trim bool values
              */
             if ($this->autoTrim && ($type != 'bool' && $type != 'int' && $data[$col] != null)) {
                 $record[$col] = trim($data[$col]);
             } else {
                 $record[$col] = $data[$col];
             }
         }
     }
     return $record;
 }
开发者ID:songhongji,项目名称:gaiaehr,代码行数:59,代码来源:MatchaCUP.php

示例3: parseValues

 /**
  * function parseValues($data):
  * Parse the data and if some values met the type correct them.
  *
  * @param $data
  *
  * @return array
  */
 private function parseValues($data)
 {
     $record = array();
     $columns = array_keys($data);
     $values = array_values($data);
     foreach ($columns as $index => $column) {
         if (!in_array($column, $this->fields)) {
             unset($columns[$index], $values[$index]);
         }
     }
     foreach ($columns as $col) {
         $properties = (array) MatchaModel::__getFieldProperties($col, $this->model);
         /**
          * Don't parse the value (skip it) if...
          * $properties['store'] is set and is not true OR
          * $properties['persist'] is set and is not true OR
          */
         if ((!isset($properties['store']) || $properties['store']) && (!isset($properties['persist']) || $properties['persist'])) {
             $type = MatchaModel::__getFieldType($col, $this->model);
             if ($this->encryptedFields !== false && in_array($col, $this->encryptedFields)) {
                 $data[$col] = $this->dataEncrypt($data[$col]);
             } else {
                 if ($type == 'date') {
                     $data[$col] = $data[$col] == '' ? null : $data[$col];
                 } elseif ($type == 'array') {
                     $data[$col] = $data[$col] == '' ? null : serialize($data[$col]);
                 }
             }
             /**
              * do not trim bool values
              */
             if ($this->autoTrim && $type != 'bool') {
                 $record[$col] = trim($data[$col]);
             } else {
                 $record[$col] = $data[$col];
             }
         }
     }
     return $record;
 }
开发者ID:nagyist,项目名称:tutus,代码行数:48,代码来源:MatchaCUP.php


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