Blogger Information
Blog 61
fans 1
comment 0
visits 69575
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0705-TP6获取器
我的博客
Original
928 people have browsed it

实例

<?php
namespace app\model\model\test;
use think\model;


class User extends model
{
 public function Attr(){
            $user = User::where('id','>','2')->select();   //select返回的是二维数组,所以出错,要使用循环来打印 echo $user->st;
            echo $user->status;   //自己理解:user表下边的st字段?  //$user 查询数据, ->st :st为字段值
            return $user;
        }
 	public function getStatusAttr($v){    //命名规则: `get` + 查询的字段名(第一个字母大写) + `Attr`
            $status = [0=>'禁用',1=>'开启'];   //拿到数据库的 0 或 1 来给他赋值。
            return $status[$v];
		}

运行实例 »

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


Correction status:qualified

Teacher's comments:
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