model 概念(笔记)

1.model 是业务模型,数据库的增删改查都集中到model里,

<?php

class test{
	protected $table = 'test';
	protected $db = null;//存放实例用的
	public function __construct(){
		$this->db = mysql::getIns();
	}

	public function reg($data){

		//db既然能被auto_Excute 说明是mysql实例
		 return $this->db->autoExcute($this->table,$data,'insert');
	}
}

  现在用的是test表,要是换一张表,就要重新__construct(),弄一个新的model,所以要搞个父类来继承他,

原文地址:https://www.cnblogs.com/a2762/p/4031075.html