thinkphp5.0的controller、medol層的定義及呼叫的實現例項
阿新 • • 發佈:2018-12-26
1、model層的設計的實現
<?php
namespace app\index\model;
use think\Model;
use think\Db;
class Member extends Model
{
protected $table='hfs_member';
public function get_member_name($member_id){
$res=Db::table($this->table)->field("account")->where('id',$member_id)->find();
return $res['account'];
}
2、controller層的設計實現及呼叫model
<?php
namespace app\index\controller;
use app\index\controller\Command;
use think\Controller;
class Index extends Controller
{
public function index()
{
$member=new Member();
$resGetName=$member->get_member_name(1);
}
}