//一、定义一个日志的方法
public function clolog($str){
$name=Session::get('uid');
$this->assign("name",$name);
$time = date('Y-m-d H:i:s');
//组织成键值对
$data = [
'name'=>$name,
'time'=>$time,
'str'=>$str,
];
$data = Db::table('log')->insert($data);
}
二、调用
$this->clolog("添加商品分类成功!");
三、
<?php
namespace appindexcontroller;
use thinkController;
use thinkDb;
use thinkSession;
class Clolog extends Common{
//日志
function clolog(){
$list = Db::name('log')->paginate(5,false,
[
'type'=>'BootstrapDetailed'
]
);
$this->assign('list', $list);
return $this->fetch();
}
}