数据库有四个表,分别是: 一、用户表 ~~~ DROP TABLE IF EXISTS `pre_common_member`; CREATE TABLE `pre_common_member` ( `uid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `username` char(15) NOT NULL DEFAULT '', `password` char(32) NOT NULL DEFAULT '', `status` tinyint(1) NOT NULL DEFAULT '0', `regdate` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`uid`), UNIQUE KEY `username` (`username`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=gbk; ~~~ 二、订单表 ~~~ DROP TABLE IF EXISTS `pre_tto_order`; CREATE TABLE `pre_tto_order` ( `oid` int(20) unsigned NOT NULL AUTO_INCREMENT, `uid` mediumint(8) unsigned NOT NULL DEFAULT '0', `tid` int(15) unsigned NOT NULL DEFAULT '0', `ap` mediumint(8) unsigned NOT NULL DEFAULT '0', `snick` char(15) NOT NULL DEFAULT '', `bnick` char(15) NOT NULL DEFAULT '', `stime` int(10) unsigned NOT NULL DEFAULT '0', `etime` int(10) unsigned NOT NULL DEFAULT '0', `oamount` decimal(10,2) NOT NULL DEFAULT '0.00', `pamount` decimal(10,2) NOT NULL DEFAULT '0.00', `damount` decimal(10,2) NOT NULL DEFAULT '0.00', `trate` float NOT NULL DEFAULT '0.7', `displayorder` tinyint(1) NOT NULL DEFAULT '0', `remark` char(255) NOT NULL DEFAULT '0', `onum` varchar(50) DEFAULT NULL, PRIMARY KEY (`oid`), KEY `uid` (`uid`), KEY `tid` (`tid`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=gbk; ~~~ 三、产品表 ~~~ DROP TABLE IF EXISTS `pre_tto_template`; CREATE TABLE `pre_tto_template` ( `uid` mediumint(8) unsigned NOT NULL DEFAULT '0', `tid` int(15) unsigned NOT NULL DEFAULT '0', `ttype` tinyint(1) NOT NULL DEFAULT '0', `highlight` tinyint(1) NOT NULL DEFAULT '0', `tname` char(50) NOT NULL DEFAULT '', `pnick` char(15) NOT NULL DEFAULT '', `dnick` char(15) NOT NULL DEFAULT '', `onick1` char(15) NOT NULL DEFAULT '', `onick2` char(15) NOT NULL DEFAULT '', `puid` mediumint(8) unsigned NOT NULL DEFAULT '0', `duid` mediumint(8) unsigned NOT NULL DEFAULT '0', `ouid1` mediumint(8) unsigned NOT NULL DEFAULT '0', `ouid2` mediumint(8) unsigned NOT NULL DEFAULT '0', `prate` float NOT NULL DEFAULT '0', `drate` float NOT NULL DEFAULT '0', `orate1` float NOT NULL DEFAULT '0', `orate2` float NOT NULL DEFAULT '0', KEY `uid` (`uid`,`tid`) ) ENGINE=MyISAM DEFAULT CHARSET=gbk; ~~~ 四、结算表 ~~~ DROP TABLE IF EXISTS `pre_tto_account`; CREATE TABLE `pre_tto_account` ( `aid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `uid` mediumint(8) unsigned NOT NULL DEFAULT '0', `ap` mediumint(8) unsigned NOT NULL DEFAULT '0', `anick` char(15) NOT NULL DEFAULT '', `pstatus` tinyint(1) NOT NULL DEFAULT '0', `amount` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`aid`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=gbk; ~~~ 新建数据库并填充测试数据。 建立数据表对应模型。 用户模型 /apps/index/model/User.php ~~~ <?php namespace app\index\model; use think\Model; class User extends Model { protected $name = 'common_member'; } ?> ~~~ 产品模型 /apps/index/model/Template.php ~~~ <?php namespace app\index\model; use think\Model; class Template extends Model { protected $name = 'tto_template'; } ?> ~~~ 订单模型 /apps/index/model/Order.php ~~~ <?php namespace app\index\model; use think\Model; class Order extends Model { protected $name = 'tto_order'; } ?> ~~~ 结算模型 /apps/index/model/Account.php ~~~ <?php namespace app\index\model; use think\Model; class Account extends Model { protected $name = 'tto_account'; } ?> ~~~