Blogger Information
Blog 14
fans 0
comment 0
visits 16072
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
读取器/修改器
依然很m丶的博客
Original
800 people have browsed it

名字 命名 get(Price)Attr($price,$data)

Index文件

<?php
namespace app\index\controller;
use \app\index\model\Shop_name;
class Index
{
    public function index()
    {
     $shop = Shop_name::get(2);
     return $shop->price;
    }
}

model/Shopname

<?php
namespace app\index\model;
use think\Model;
class Shop_name extends Model
{
   protected function getPriceAttr($price,$data)
   {
       return $data['name'].$price;
   }
}

只需要改价格

修改器

Index

<?php
namespace app\index\controller;
use \app\index\model\Shop_name;
class Index
{
   public function index()
   {
       $shop = new Shop_name;
       $shop->name ='php';
       $shop->price='12';
       $shop->type='php';
       if ($shop->save()){
           return '保存成功';
       }else{
           return $shop->getError();
       }
   }

model/Shopname

<?php
namespace app\index\model;
use think\Model;
class Shop_name extends Model
{
 protected function setPriceAttr($price)
 {
     return $price;
 }
}

只需要改价格

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