Thinkphp 使用mode

3.2使用方式

控制器

<?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;
}
}
  


posted @ 2019-05-15 15:13  你的阿阳  阅读(567)  评论(0)    收藏  举报