Thinkphp 使用mode
3.2使用方式
控制器
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。<?php
namespace Admin\Controller;
class UsersController extends AdminBaseController
{
public function index()
{
$info = D('Users')->get_one_form($data['id']);
}
Modle
<?php
namespace Admin\Model;
use Think\Model;
class UsersModel extends Model
{
public function get_one_form($id){
$where['id'] = $id;
$where['display'] = 1;
$info = M('Users')->where($where)->find();
return $info;
}
}
5.0 使用方式
<?php
namespace app\index\controller;
use \think\Cache;
use \think\Controller;
use think\Loader;
use think\Db;
use \think\Cookie;
use \think\Session;
class Activity extends Home
{
public function hot(){
$user = model('ActivityList')->get_one_from_id($style,$user_id);
}
}
<?php
namespace app\index\model;
use \think\Model;
class ActivityList extends Model
{
public function get_one_from_id($style,$id){
$info = $this->where(['uid'=>$id,'style'=>$style,'display'=>0])->order('add_time desc')->select();
return $info;
}
}

更多精彩