| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace app\common;
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/6/22
- * Time: 12:51
- */
- use think\Db;
- class tools
- {
- public static function writedebuglog($type, $data)
- {
- if (!is_string($data)) {
- $data = json_encode([$data, 256]);
- }
- Db::table('debug_log')->insert(['mtype' => $type, 'data' => $data]);
- }
- public static function getKfGroup($cache = 1, $all = 0)
- {
- $key = md5(__FILE__ . 'getKfGroup');
- if ($cache) {
- $cval = cache($key);
- if ($cval) {
- return $cval;
- }
- }
- $return = [];
- if ($all) {
- $ret = Db::name('groups')->all();
- } else {
- $ret = Db::name('groups')->where('status', 1)->select();
- }
- foreach ($ret as $val) {
- $return[$val['id']] = $val['name'];
- }
- cache($key, $return, ['expire' => 600]);
- return $return;
- }
- }
|