1、Volist標籤主要用於在模板中循環輸出數據集或者多維數組。
2、
前臺顯示ip和time 建表的時候兩個數據類型都選vachar,然後在添加數據的時候
public function add(){
import('ORG.Util.Date');
$user=D('liuyan');
if($vo=$user->create()){
echo 'create成功';
$list = array('title' => I('title'),
'content'=> I('content'),
'time'=> time(),
'name'=>I('name'),
'tel'=>I('tel'),
'email'=>I('email'),
'ip'=>get_client_ip());
if ($user->add($list)){
$list['id']=$id;
$list['title']=$title;
$list['time'] = date('Y-m-d H:i:s', time());
$list['ip'] = $_SERVER['REMOTE_ADDR'];
$this->success("發佈留言成功");
}else{
$this->error($user->getError());
}
}else{
echo 'create失敗';
$this->error($user->getError());
}
3、
分頁功能
$User=M("liuyan");
import('ORG.Util.Page');
$count = $User->count();
$Page= new Page($count ,5);
$limit= $Page->firstRow . ',' . $Page->listRows;
$show =$Page->show();// 分頁顯示輸出
$list= $User->order('time')->limit($limit)->select();
$this->assign('list',$list);
$this->assign('page',$show);
$this->display();
再在模板頁面中寫上
<div class="result page">{$page}</div>