方法一:
public function index(){ $Member = new MemberModel(); $money = $Member->Money(3); print_r($money); }
方法二:
1.use 导入模型MemberModel
2.引用模型的方法 $this->ss();
MemberModel.class.php
namespace PortalModel; use ThinkModel; 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 MemberController; use PortalModelMemberModel; class IndexController extends MemberBaseController{ public function index(){ $money = new MemberModel; $money = $money->Money(3); $fiels['money'] = $money; $this->assign('vo',$fiels); $this->display(); } }