本文整理汇总了PHP中format::read_date方法的典型用法代码示例。如果您正苦于以下问题:PHP format::read_date方法的具体用法?PHP format::read_date怎么用?PHP format::read_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format
的用法示例。
在下文中一共展示了format::read_date方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Put data into cache
*
* @param string $cache_id
* @param mixed $data
* @param mixed $tags
* @param int $expire
* @return boolean
*/
public function set($cache_id, $data, $tags = [], $expire = null)
{
if (!empty($tags)) {
$tags = ' ' . implode(' ', array_fix($tags)) . ' ';
} else {
$tags = null;
}
// processing expire
if (empty($expire)) {
$expire = format::now('timestamp', ['add_seconds' => $this->options['expire']]);
} else {
$expire = format::read_date($expire, 'datetime');
}
// generating array for saving
$save = ['sm_cache_id' => $cache_id . '', 'sm_cache_time' => format::now('timestamp'), 'sm_cache_expire' => $expire, 'sm_cache_data' => json_encode($data), 'sm_cache_tags' => $tags];
$save_result = $this->model_cache->save($save);
return $save_result['success'];
}
示例2: process_single_column_type
/**
* Process single type for column
*
* @param string $column_name
* @param array $column_options
* @param mixed $value
* @return array
*/
public static function process_single_column_type($column_name, $column_options, $value, $options = [])
{
$result = [];
// processing as per different data types
if ($column_options['type'] == 'boolean') {
// booleans
$result[$column_name] = !empty($value) ? 1 : 0;
} else {
if (in_array($column_options['type'], ['smallserial', 'serial', 'bigserial'])) {
if (format::read_intval($value, ['valid_check' => 1])) {
$temp = format::read_intval($value);
if ($temp !== 0) {
$result[$column_name] = $temp;
}
} else {
$result[$column_name . '_is_serial_error'] = true;
}
$result[$column_name . '_is_serial'] = true;
} else {
if (in_array($column_options['type'], ['smallint', 'integer', 'bigint'])) {
// integers
// if we got empty string we say its null
if (is_string($value) && $value === '') {
$value = null;
}
if (is_null($value)) {
if (!empty($column_options['null']) || !empty($options['ignore_defaults'])) {
$result[$column_name] = null;
} else {
$result[$column_name] = $column_options['default'] ?? 0;
}
} else {
$result[$column_name] = format::read_intval($value);
}
} else {
if (in_array($column_options['type'], ['numeric', 'bcnumeric'])) {
// numerics as floats or strings
// if we got empty string we say its null
if (is_string($value) && $value == '') {
$value = null;
}
if (is_null($value)) {
if (!empty($column_options['null']) || !empty($options['ignore_defaults'])) {
$result[$column_name] = null;
} else {
$result[$column_name] = $column_options['default'] ?? ($column_options['type'] == 'bcnumeric' ? '0' : 0);
}
} else {
$result[$column_name] = format::read_floatval($value, ['bcnumeric' => $column_options['type'] == 'bcnumeric']);
}
} else {
if (in_array($column_options['type'], ['date', 'time', 'datetime', 'timestamp'])) {
$result[$column_name] = format::read_date($value, $column_options['type']);
// for datetime we do additional processing
if (!empty($options['process_datetime'])) {
$result[$column_name . '_strtotime_value'] = 0;
if (!empty($value)) {
$result[$column_name . '_strtotime_value'] = strtotime($result[$column_name]);
}
}
} else {
if ($column_options['type'] == 'json') {
if (is_null($value)) {
$result[$column_name] = null;
} else {
if (is_array($value)) {
$result[$column_name] = json_encode($value);
} else {
$result[$column_name] = (string) $value;
}
}
} else {
if (is_null($value)) {
$result[$column_name] = null;
} else {
$result[$column_name] = (string) $value;
}
}
}
}
}
}
}
return $result;
}