<?php
namespace app\index\controller;
use app\index\model\Classed;
use app\index\model\Student;
use think\Controller;
class StudentController extends Controller
{
public function index()
{
$studnet = new Student();
$studnets = $studnet->all();
$this->assign("students", $studnets);
return $this->fetch();
}
public function create()
{
$classed = Classed::all();
$this->assign("classed", $classed);
$this->fetch();
}
public function create1()
{
$this->fetch();
}
public function wangzhijun()
{
$this->fetch();
}
public function save()
{
$name = input("name");
$age = input("age");
$email = input("email");
$classId = input("classId");
$studnet = new Student();
$result = $studnet->save([
"name" => $name,
"age" => $age,
"email" => $email,
"classId" => $classId
]);
if ($result) {
$this->success("创建成果", 'Student/index');
}
}
public function edit()
{}
}下面是能访问的日志:---------------------------------------------------------------
[ 2017-12-28T07:35:04+08:00 ] 127.0.0.1 GET /school/public/index.php/index/student/index.html
[ info ] 127.0.0.1/school/public/index.php/index/student/index.html [运行时间:0.062003s][吞吐率:16.13req/s] [内存消耗:1,977.34kb] [文件加载:46]
[ info ] [ LANG ] D:\WWW\school\thinkphp\lang\zh-cn.php
[ info ] [ ROUTE ] array (
'type' => 'module',
'module' =>
array (
0 => 'index',
1 => 'student',
2 => 'index',
),
)
[ info ] [ HEADER ] array (
'cookie' => 'thinkphp_show_page_trace=0|0',
'accept-language' => 'zh-CN,zh;q=0.9',
'accept-encoding' => 'gzip, deflate, br',
'accept' => 'text/html,application/xhtml+xm
'upgrade-insecure-requests' => '1',
'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
'connection' => 'close',
'host' => '127.0.0.1',
)
[ info ] [ PARAM ] array (
)
[ info ] [ RUN ] app\index\controller\StudentController->index[ D:\WWW\school\application\index\controller\StudentController.php ]
[ info ] [ DB ] INIT mysql
[ info ] [ VIEW ] D:\WWW\school\public/../application/index\view\student\index.html [ array (
0 => 'students',
) ]
[ info ] [ LOG ] INIT File
[ sql ] [ DB ] CONNECT:[ UseTime:0.013001s ] mysql:host=127.0.0.1;dbname=test;charset=utf8
[ sql ] [ SQL ] SHOW COLUMNS FROM `student` [ RunTime:0.009001s ]
[ sql ] [ SQL ] SELECT * FROM `student` [ RunTime:0.001000s ]
下面是不能访问的日志:
---------------------------------------------------------------
[ 2017-12-28T07:27:54+08:00 ] 127.0.0.1 GET /school/public/index.php/index/student/wangzhijun
[ info ] 127.0.0.1/school/public/index.php/index/student/wangzhijun [运行时间:0.022002s][吞吐率:45.45req/s] [内存消耗:1,115.13kb] [文件加载:38]
[ info ] [ LANG ] D:\WWW\school\thinkphp\lang\zh-cn.php
[ info ] [ ROUTE ] array (
'type' => 'module',
'module' =>
array (
0 => 'index',
1 => 'student',
2 => 'wangzhijun',
),
)
[ info ] [ HEADER ] array (
'cookie' => 'thinkphp_show_page_trace=0|0',
'accept-language' => 'zh-CN,zh;q=0.9',
'accept-encoding' => 'gzip, deflate, br',
'accept' => 'text/html,application/xhtml+xm
'upgrade-insecure-requests' => '1',
'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
'cache-control' => 'max-age=0',
'connection' => 'close',
'host' => '127.0.0.1',
)
[ info ] [ PARAM ] array (
)
[ info ] [ RUN ] app\index\controller\StudentController->wangzhijun[ D:\WWW\school\application\index\controller\StudentController.php ]
[ info ] [ VIEW ] ewangzhijun.html [ array (
) ]
[ info ] [ LOG ] INIT File
最佳答案