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');
}
}