diff --git a/app/admin/controller/Forum.php b/app/admin/controller/Forum.php index a07b28f..aa7e3f0 100644 --- a/app/admin/controller/Forum.php +++ b/app/admin/controller/Forum.php @@ -127,14 +127,33 @@ class Forum extends AdminController public function replys() { if(Request::isAjax()) { - $replys = Comment::with(['user','article'])->paginate(15); +/* + $replys = Comment::field('id,article_id,user_id,content,create_time')->with([ + 'user' => function($query){ + $query->field('id,name,user_img'); + }, + 'article' => function($query){ + $query->field('id,title'); + } + ])->paginate(15); +*/ + $replys = Db::name('comment') + ->alias('a') + ->join('user u','a.user_id = u.id') + ->join('article c','a.article_id = c.id') + ->field('a.id as aid,name,title,user_img,a.content as content,a.create_time as create_time') + ->where('a.delete_time',0) + ->order('a.create_time', 'desc') + ->paginate(15); + $count = $replys->total(); $res = []; if ($replys) { $res = ['code'=>0,'msg'=>'','count'=>$count]; foreach($replys as $k => $v){ //var_dump($v); - $res['data'][] = ['id'=>$k+1,'replyer'=>$v->user->name,'cardid'=>$v->article->title,'avatar'=>$v->user->user_img,'content'=>$v['content'],'replytime'=>$v['create_time']]; + //$res['data'][] = ['id'=>$v['id'],'replyer'=>$v->user->name,'cardid'=>$v->article->title,'avatar'=>$v->user->user_img,'content'=>$v['content'],'replytime'=>$v['create_time']]; + $res['data'][] = ['id'=>$v['aid'],'replyer'=>$v['name'],'cardid'=>$v['title'],'avatar'=>$v['user_img'],'content'=>$v['content'],'replytime'=>$v['create_time']]; } } return json($res); diff --git a/app/index/controller/Error.php b/app/index/controller/Error.php index 733cbf1..e1b236a 100644 --- a/app/index/controller/Error.php +++ b/app/index/controller/Error.php @@ -1,10 +1,13 @@ '127.0.0.1', // 数据库名 - 'database' => '', + 'database' => 'taotest', // 用户名 - 'username' => '', + 'username' => 'root', // 密码 - 'password' => '', + 'password' => 'root', // 端口 'hostport' => '3306', // 数据库连接参数 diff --git a/app/install/controller/Index.php b/app/install/controller/Index.php index 11d51a4..c698303 100644 --- a/app/install/controller/Index.php +++ b/app/install/controller/Index.php @@ -128,10 +128,13 @@ php; //管理员 $table_admin = $data['DB_PREFIX'] . "admin"; $table_user = $data['DB_PREFIX'] . "user"; + $table_system = $data['DB_PREFIX'] . "system"; $sql_admin = "UPDATE $table_admin SET username = '{$username}', password = '{$pass}', status=1,create_time = '{$create_time}' WHERE id = 1"; $sql_user = "UPDATE $table_user SET name = '{$username}', password = '{$pass}', status=1, auth=1, create_time = '{$create_time}' WHERE id = 1"; + $sql_syste = "UPDATE $table_system SET create_time = '{$create_time}' WHERE id = 1"; $db->execute($sql_admin); $db->execute($sql_user); + $db->execute($sql_syste); Db::getConnection()->close(); } diff --git a/config/app.php b/config/app.php index 45ca00d..18feded 100644 --- a/config/app.php +++ b/config/app.php @@ -29,7 +29,7 @@ return [ 'deny_app_list' => [], // 异常页面的模板文件 - 'exception_tmpl' => '../veiw/404.html', + 'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl', // 错误显示信息,非调试模式有效 'error_message' => '页面错误!请稍后再试~', diff --git a/config/database-1.php b/config/database-1.php new file mode 100644 index 0000000..dcff575 --- /dev/null +++ b/config/database-1.php @@ -0,0 +1,63 @@ + Env::get('database.driver', 'mysql'), + + // 自定义时间查询规则 + 'time_query_rule' => [], + + // 自动写入时间戳字段 + // true为自动识别类型 false关闭 + // 字符串则明确指定时间字段类型 支持 int timestamp datetime date + 'auto_timestamp' => true, + + // 时间字段取出后的默认时间格式 + 'datetime_format' => 'Y-m-d H:i:s', + + // 数据库连接配置信息 + 'connections' => [ + 'mysql' => [ + // 数据库类型 + 'type' => Env::get('database.type', 'mysql'), + // 服务器地址 + 'hostname' => Env::get('database.hostname', '127.0.0.1'), + // 数据库名 + 'database' => Env::get('database.database', ''), + // 用户名 + 'username' => Env::get('database.username', 'root'), + // 密码 + 'password' => Env::get('database.password', ''), + // 端口 + 'hostport' => Env::get('database.hostport', '3306'), + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => Env::get('database.charset', 'utf8'), + // 数据库表前缀 + 'prefix' => Env::get('database.prefix', ''), + + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 是否需要断线重连 + 'break_reconnect' => false, + // 监听SQL + 'trigger_sql' => true, + // 开启字段缓存 + 'fields_cache' => false, + // 字段缓存路径 + 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR, + ], + + // 更多的数据库配置信息 + ], +]; \ No newline at end of file diff --git a/config/database.php b/config/database.php index bf6edb5..61ae363 100644 --- a/config/database.php +++ b/config/database.php @@ -16,11 +16,11 @@ return [ // 服务器地址 'hostname' => '127.0.0.1', // 数据库名 - 'database' => '', + 'database' => 'taotao', // 用户名 - 'username' => '', + 'username' => 'root', // 密码 - 'password' => '', + 'password' => 'root', // 端口 'hostport' => '3306', // 数据库连接参数 diff --git a/view/404.html b/view/404.html new file mode 100644 index 0000000..a41ed6d --- /dev/null +++ b/view/404.html @@ -0,0 +1,57 @@ + + +
+ +页面或者数据被 纸飞机 运到火星了,啥都看不到了…
+页面或者数据被 纸飞机 运到火星了,啥都看不到了…
+