thinkphp5 模型获取器
Genius 发布于 阅读:50
控制层
<?php
namespace app\before\controller;
use think\Controller;
use think\Db;
use app\before\model\Article as ArticleModel;
class Article extends Controller
{
public function fanyi(){
$shuchu = ArticleModel::get(2);
return json($shuchu);
}
}
?>
模型层
<?php
namespace app\before\model;
use think\Model;
class Article extends Model
{
protected $pk = 'article_id';
public function getcatIdAttr($status){
$bianliang = [1=> '是1啊',2=>'是2啊'];
return $bianliang[$status];
}
}
?>