fetchAll('select * from cj_auth_rule where status = 1'); $authList = array_column($authList, 'id'); $authList = implode(',', $authList); // 设置数据 $rows= [ [ 'title' => '管理员' ,'rules' => $authList ,'miaoshu' => '拥有所有权限' ,'create_time' => time() ,'update_time' => time() ] ]; $serRows = $this->fetchAll('select * from cj_auth_group'); if($rows[0]['rules'] == '' || (is_array($serRows) && count($serRows) > 0)) { $rows = array(); return; } // 保存数据 $this->table('auth_group')->insert($rows)->save(); } }