添加: public function postAddto(){
$data = $_POST;
$data = $this->fliter_data($data);
$res = DB::table('news')->insert($data);
if($res){
return redirect('test/show');
}else{
return redirect('test/addto');
}
}
//删除
public function delete(){
$id = $_GET;
$data = DB::table('news')->where(['id'=>$id])->delete();
if($data){
return redirect('show');
}else{
echo '有问题,快修改一下!';
}
}
//修改
public function find(){
$id = $_GET;
// var_dump($id);die;
$arr = DB::table('news')->where(['id'=>$id])->get();
// print_r($arr);die;
return view('site/find',['arr'=>$arr[0]]);
}
public function save(){
$data = $_POST;
unset($data['_token']);
$res = DB::table('news')->where(['id'=>$data['id']])->update($data);
// var_dump($res);die;
if($res){
return redirect('show');
}else{
echo '修改失败,请重新修改';
}
}
分页
$count = $this->PuthHeartRate
->where('uid',$uid)
->where('status',0)
->orderBy('id','desc')
->count();
if($data['page'] == 1){
$start = 0;
}else{
$start = ($data['page']-1) * $data['pagesize'];
}
$re['result'] = $this->PuthHeartRate
->where('uid',$uid)
->where('status',0)
// ->limit(2)
// ->offset(0)
->take($data['pagesize'])
->skip($start)
->orderBY('id','desc')
->select('id','heart_rate')
->get();
$type = DB::select('select id,title_img from article where `type` > ? and `status` = ? limit ?,5', [2,0,($page-1)*5]);
$count = DB::table('article')->where('type', '>', 2)->where('status',0)->get(['id','title_img'])->count();