将数据库字段为下划线命名的方式转成小驼峰命名,再存入redis
2018-01-23 11:36
555 查看
tp5数据库输入存入远程Redis
tp5,将数据库字段为下划线命名的方式转成小驼峰命名,再存入redisconfig配置
'cache' => [ // 使用复合缓存类型 'type' => 'complex', // 默认使用的缓存 'default' => [ // 驱动方式 'type' => 'File', // 缓存保存目录 'path' => CACHE_PATH, ], // redis缓存 'redis' => [ // 驱动方式 'type' => 'redis', // 服务器地址 'host' => 'xxx.xx.xxx.xx', 'password' => 'xxxxxx', ],
php代码
use think\Cache; public function change($str) { $res = $str; foreach ($str as $keys => $values) { $str = ucwords(str_replace('_', ' ', $values)); $str = str_replace(' ', '', lcfirst($str)); $a[$keys] = $str; } foreach ($a as $key => $value) { $array[$key]= json_decode($value, true); } return $array; } public function do_redis() { $alms1 = $this->alms->selRedis(); $alms2 = ConfigRedis::change($alms1); $alms3 = json_encode($alms2,JSON_UNESCAPED_UNICODE); Cache::store('redis')->set('config:alms',$alms3); }
如图
相关文章推荐
- mybatis数据库字段带下划线,映射支持java类属性驼峰命名
- 驼峰式命名的字符串与数据库字段下划线大写方式的转换
- mybatis数据库字段带下划线,映射支持java类属性驼峰命名
- mybatis数据库字段带下划线,映射支持java类属性驼峰命名
- mybatis 数据库字段下划线命映射驼峰命名实体类
- SSM 数据库字段带下划线(查询结果为空),需开启驼峰映射
- myBatis配置实现数据库字段下划线映射到java对象的驼峰式命名属性
- Mybatis开启数据库字段自动映射为驼峰命名
- mybatis开启数据库字段自动映射为java驼峰命名规则
- mybatis开启数据库字段自动映射为java驼峰命名规则
- myBatis配置实现数据库字段下划线映射到java对象的驼峰式命名属性
- mybatis开启数据库字段自动映射为java驼峰命名规则
- 驼峰-匈牙利-帕斯卡-下划线命名法
- 图片以二进制的方式存入数据库,以及取出图片
- 用位域枚举作将多个 Boolean 值存入数据库的同一个字段
- 如何把数组做为一个字段存入存入数据库
- VBA实现数据库中的字段处理(下划线去掉,后面的字母变大写)之版本1.1。
- java项目启动后,数据库字段生成 user_name带下划线这种形式的
- 数据库字段为Date类型,插入操作时如何set值存入数据库。
- 驼峰法和下划线命名法的互相转换