Blogger Information
Blog 63
fans 1
comment 0
visits 75912
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
写thinkphp6的模型获取器
桃儿的博客
Original
1226 people have browsed it

写thinkphp6的模型获取器

controller文件

实例

<?PHP
namespace app\index\controller;
use app\BaseController;
use app\index\model\Admins;
class Index extends BaseController
{
    public function index()
    {
        $db = new Admins();
        $index = $db->index();
        print_r($index->status);
        print_r($index->time);
    }
}

运行实例 »

点击 "运行实例" 按钮查看在线实例

模型文件

实例

<?php
namespace app\index\model;
use think\Model;
class Admins extends Model{
    public function index(){
        $user = Admins::find(1);
//        echo $user->status;
//        echo $user->time;
        return $user;
    }
    public function getStatusAttr($v){
        $status = [0=>'禁用',1=>'开启'];
        return $status[$v];
    }
    public function getTimeAttr($v){
       return $v;
    }
}

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post