<?php namespace appdemocontroller; use thinkController; use thinkCache; class Huancun extends Controller{ public function test(){ //$data = db('student')->select(); //使用系统类 //Cache::set('studentData',$data,300); //使用助手函数 //cache('studentData',$data,300); //return view(); /*if($data = cache('studentData')){ }else{ $data = db('student')->select(); cache('studentData', $data, 30); }*/ //dump($data); $data = db('student')->paginate(3); $this->assign('data',$data); return view(); } public function uploadsView(){ return view(); } public function uploads(){ $request = request(); $file = $request->file('upfile'); $info = $file->move(ROOT_PATH.'public/uploads'); if($info){ echo $info->getExtension(); echo $info->getSaveName(); echo $info->getFilename(); }else{ // echo $file->getError(); } } } //session /* namespace appdemocontroller; use thinkController; use thinkSession; class Index extends Controller{ public function setSession(){ //设置session Session::set('name','zhangsan'); session('name','zhangsan'); } public function getSession(){ //读取session return Session::get('name'); return session('name'); } public function pSession(){ //判断session存不存在 return Session::has('name'); } public function delSession(){ //删除session Session::delete('name'); session('name',null); } }*/ //Cookie /*namespace appdemocontroller; use thinkController; use thinkCookie; class Index extends Controller{ public function setcookie(){ //设置cookie Cookie::set('name','zhangsan',3600); cookie('name','zhangsan',3600); } public function getcookie(){ //读取cookie return Cookie::get('name'); return cookie('name'); } public function pcookie(){ //判断cookie存不存在 return Cookie::has('name'); } public function delcookie(){ //删除cookie Cookie::delete('name'); cookie('name',null); } }*/ ?>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <table border="" cellspacing="" cellpadding=""> <tr> <td>学号</td> <td>名字</td> <td>班级</td> </tr> {volist name='data' id='value'} <tr> <td>{$value.Sno}</td> <td>{$value.Sname}</td> <td>{$value.Class}</td> </tr> {/volist} </table> {$data->render()} </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form action="{:url('uploads')}" method="post" enctype="multipart/form-data"> <input type="file" name="upfile" id="upfile" value="" > <input type="submit" value="提交"/> </form> </body> </html>