本文整理匯總了PHP中MatchaModel::__getFieldType方法的典型用法代碼示例。如果您正苦於以下問題:PHP MatchaModel::__getFieldType方法的具體用法?PHP MatchaModel::__getFieldType怎麽用?PHP MatchaModel::__getFieldType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MatchaModel
的用法示例。
在下文中一共展示了MatchaModel::__getFieldType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)
{
$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;
}