Thinkphp 數據模型大M()方法和大D()方法

在操作數據庫,實例化表的時候你會看大M()方法和大D()方法,他們都可以實例化表,但是也有不同的地方,下面詳細講述內容

1,M()方法  D()方法

<?php
namespace Home\Controller;
use Think\Model;

/**
 *  類繼承公共類
 *  功能 :主頁跟子頁面分類數據
*/

class IndexController extends CommController {
    public function index(){
          //網店配置
          $this->assign('siteconfig',$GLOBALS['siteconfig']);
          //顯示友情鏈接
          $this->assign('alllinks',$GLOBALS['alllinks']);  
          $Model=D('Goods');
          $type = D('type');
          $res=$type->where("pid=0")->select();
          foreach ($res as $k => $v) {
             $yi=$type->where("pid=".$v['id'])->limit(3)->select();
             $res[$k]['cc']=$yi;
          }
          //品牌
          $pp   = M('Brand'); //品牌表
          $ppg  = $pp->where("typeid=1")->select(); //1.的品牌

         $this->display();
    }

2,數據模型建立

文章來自(www.dc3688.com)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章