商城笔记(MVC模式1) —— Model类概念

Model.class.php

class Model {
    protected $table = null; // model所控制的表
    protected $db = null; // 引入的mysql对象

    public function __construct() {
        $this->db = mysql::getIns();
    }
}

TestModel.class.php

// 先加载model才能testmodel
class TestModel extends Model{

    public function reg($data) {
        return $this->db->autoExecute($this->table,$data,'insert');
    }
}


class GoodsModel extends Model {
    protected $table = 'Goods';
    protected $db = null;

    // 用户注册的方法
    /*
        $data array();
    */

    public function __construct() { 
        $this->db = mysql::getIns();
    }

    public function reg($data) {
        return $this->db->autoExecute($this->table,$data,'insert');
    }
}

这里写图片描述

这里写图片描述

猜你喜欢

转载自blog.csdn.net/dyw_666666/article/details/81021941