3.2使用方式

控制器

  1. <?php
    namespace Admin\Controller;

    class UsersController extends AdminBaseController
    {
    public function index()
    {
  1.     $info = D(\'Users\')->get_one_form($data[\'id\']);
  1.   }
    Modle
  1. <?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 使用方式
  1. <?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);
    }
    }
  1. <?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;
    }
    }
  1.   


版权声明:本文为syay原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/syay/p/10869581.html