thinkphp3.2 控制器导入模型
方法一:
public function index(){ $Member = new MemberModel(); $money = $Member->Money(3); print_r($money); }
方法二:
1.use 导入模型MemberModel
2.引用模型的方法 $this->ss();
MemberModel.class.php
namespace Portal\Model; use Think\Model; class MemberModel extends Model { public function Money($id){ $where['id'] = $id; $res = M('member')->where($where)->field('money')->find(); return $res['money']; } }
控制器导入
IndexController.class.php
<?php namespace Member\Controller; use Portal\Model\MemberModel; class IndexController extends MemberBaseController{ public function index(){ $money = new MemberModel; $money = $money->Money(3); $fiels['money'] = $money; $this->assign('vo',$fiels); $this->display(); } }