'主表',
'form'=>'实例表',
'param'=>'主参数表',
'order'=>'数据提交/收集表单表',
'addon'=>'附加参数表',
'data'=>'具体数据表',
'attr'=>'数据属性微调表',
'pre'=>'数据表预编辑操作记录',
];
}
}
/*
数据表过滤校验字段集
$suffix 表后缀类型
*/
function table_fileds($suffix)
{
switch($suffix) {
case 'self':
$fields = ['title','keywords','displayorder','status','deleted','statuscode'];
break;
case 'form':
$fields = ['s_sn','uid','title','value','displayorder','status','deleted','statuscode'];
break;
case 'param':
$fields = ['s_sn','f_sn','uid','setfor','title','key','value','displayorder','status','deleted','statuscode'];
break;
case 'order':
$fields = ['s_sn','f_sn','mid','fid','title','value','displayorder','status','deleted','statuscode'];
break;
case 'addon':
$fields = ['s_sn','f_sn','o_sn','mid','fid','setfor','title','key','value','displayorder','status','deleted','statuscode'];
break;
case 'data':
$fields = ['s_sn','f_sn','o_sn','mid','fid','setfor','title','key','value','displayorder','status','deleted','statuscode'];
break;
case 'attr':
$fields = ['t_sn','uid','mid','fid','suffix','setfor','title','key','value','displayorder','status','deleted','statuscode'];
break;
case 'pre':
$fields = ['tid','uid','mid','fid','suffix','setfor','value','displayorder','status','deleted','statuscode'];
break;
default:
$fields = ['id','sn','siteid','platid','uniacid','shopid','createtime','updatetime','update_at'];
break;
}
return $fields;
}
/*
数据过滤校验
*/
function data_filter($dataPost)
{
$newData = array();
//需要直接过滤掉的部分
$keys = ['id','siteid','createtime','updatetime','update_at'];
foreach($keys as $key){
if(isset($dataPost[$key])){
unset($dataPost[$key]);
}
}
//需要从GET中取得的字段,此处也需过滤掉
$keys = ['uniacid','platid','shopid'];
foreach($keys as $key){
if(isset($dataPost[$key])){
unset($dataPost[$key]);
}
}
//格式化为整型数字并保留的字段
$keys = ['displayorder','status','statuscode','deleted'];
foreach($keys as $key){
if(isset($dataPost[$key])){
$dataPost[$key] = intval($dataPost[$key]);
$newData[$key] = intval($dataPost[$key]);
}
}
//格式化为整型数字但不保留的字段
$keys = ['partnerid','uid','mid','fid'];
foreach($keys as $key){
if(isset($dataPost[$key])){
$newData[$key] = intval($dataPost[$key]);
unset($dataPost[$key]);
}
}
//约定SQL命令辅助(sql_开头)
$keys = ['orders','limits'];
foreach($keys as $key){
if(isset($dataPost['sql_'.$key]) && is_array($dataPost['sql_'.$key])) {
$newData['sqls'][$key] = $dataPost['sql_'.$key];
unset($dataPost['sql_'.$key]);
}else{
$newData['sqls'][$key] = array();
}
}
//约定搜索条件辅助(searchings数组)
/*
@status 指定状态(数据是否启用)(0,1)
@deleted 指定状态(数据是否删除)(0,1)
@keyword 指定要匹配的关键词(模糊检索)
@filter 用于设定数据过滤条件(数组集,要匹配的字段=》字段值)($col=>$val)
@plat 指定跨平台搜索
*/
$keys = ['status','deleted','keyword','filter','plat'];
$newData['searching'] = array();
foreach($keys as $key){
if(isset($dataPost['searching'][$key])) {
$newData['searching'][$key] = $dataPost['searching'][$key];
unset($dataPost['searching'][$key]);
}
}
$hasSearchAddons = (isset($dataPost['searching']) && count($dataPost['searching'])>0) ? true : false;
if($hasSearchAddons){
$newData['searching']['addons'] = array();
foreach($dataPost['searching'] as $key => $value){
$newData['searching']['addons'][$key] = $value;
unset($dataPost['searching'][$key]);
}
}
unset($dataPost['searching']);
//初始化赋值 TBD
$keys = ['statuscode'=>64];
//剩余部分
$newData['addons'] = array();
foreach($dataPost as $key => $v){
$newData['addons'][$key] = $v;
}
return $newData;
}
/*
根据表功能类型进行数据格式化
*/
function data_format($data,$suffix)
{
global $_FM;
$newData = array();
switch($suffix){
case 'self':
//取各类型表字段
$columns1 = $this->table_fileds($suffix);
$columns2 = $this->table_fileds('');
//去除非字段集内的部分
foreach($data as $key => $v){
if(in_array($key,$columns1) || in_array($key,$columns2)){
$newData[$key] = $data[$key];
}
}
//进一步整理
$newData['siteid'] = $_FM['apiCert']['siteId'];
$newData['platid'] = $_FM['platid'];
$newData['uniacid'] = $_FM['uniacid'];
$newData['shopid'] = $_FM['shopid'];
break;
case 'form':
//取各类型表字段
$columns1 = $this->table_fileds($suffix);
$columns2 = $this->table_fileds('');
//去除非字段集内的部分
foreach($data as $key => $v){
if(in_array($key,$columns1) || in_array($key,$columns2)){
$newData[$key] = $data[$key];
}
}
//进一步整理
$newData['siteid'] = $_FM['apiCert']['siteId'];
$newData['platid'] = $_FM['platid'];
$newData['uniacid'] = $_FM['uniacid'];
$newData['shopid'] = $_FM['shopid'];
break;
case 'order':
//取各类型表字段
$columns1 = $this->table_fileds($suffix);
$columns2 = $this->table_fileds('');
//去除非字段集内的部分
foreach($data as $key => $v){
if(in_array($key,$columns1) || in_array($key,$columns2)){
$newData[$key] = $data[$key];
}
}
//进一步整理
$newData['siteid'] = $_FM['apiCert']['siteId'];
$newData['platid'] = $_FM['platid'];
$newData['uniacid'] = $_FM['uniacid'];
$newData['shopid'] = $_FM['shopid'];
break;
case 'param':
//要在此处格式化掉sn等数据
$reset = ['sn','s_sn','f_sn','o_sn'];
foreach($data as $key => $value)
{
if(in_array($key,$reset)) {
unset($data[$key]);
}
}
foreach($data as $key => $value)
{
$temp = array();
$setfor = $key; //析取setfor
$temp['setfor'] = $setfor;
if(is_array($value))
{
//仍是数组,继续
foreach($value as $k => $v)
{
$title = $k; //析取title
$temp['title'] = $k;
if(is_array($v))
{
//仍是数组,继续
foreach($v as $kk => $vv){
$temp['key'] = $kk; //析取key
$temp['value'] = serialize($vv); //不再往下构造了——三级数组保存式(setfor-title-key=>value)
$newData[] = $temp;
}
}else{
$temp['key'] = $k;
$temp['value'] = serialize($v);
$newData[] = $temp;
}
}
}else{
$temp['title'] = $setfor;
$temp['key'] = $setfor;
$temp['value'] = serialize($value);
$newData[] = $temp;
}
}
break;
case 'addon':
//要在此处格式化掉sn等数据
$reset = ['sn','s_sn','f_sn','o_sn','partnerid','mid','fid'];
foreach($data as $key => $value)
{
if(in_array($key,$reset)) {
unset($data[$key]);
}
}
foreach($data as $key => $value)
{
$temp = array();
$setfor = $key; //析取setfor
$temp['setfor'] = $setfor;
if(is_array($value))
{
//仍是数组,继续
foreach($value as $k => $v)
{
$title = $k; //析取title
$temp['title'] = $k;
if(is_array($v))
{
//仍是数组,继续
foreach($v as $kk => $vv){
$temp['key'] = $kk; //析取key
$temp['value'] = serialize($vv); //不再往下构造了——三级数组保存式(setfor-title-key=>value)
$newData[] = $temp;
}
}else{
$temp['key'] = $k;
$temp['value'] = serialize($v);
$newData[] = $temp;
}
}
}else{
$temp['title'] = $setfor;
$temp['key'] = $setfor;
$temp['value'] = serialize($value);
$newData[] = $temp;
}
}
break;
case 'data':
//要在此处格式化掉sn等数据
$reset = ['sn'];
foreach($data as $key => $value)
{
if(in_array($key,$reset)) {
unset($data[$key]);
}
}
foreach($data as $key => $value)
{
$temp = array();
$setfor = $key; //析取setfor
$temp['setfor'] = $setfor;
if(is_array($value))
{
//仍是数组,继续
foreach($value as $k => $v)
{
$title = $k; //析取title
$temp['title'] = $k;
if(is_array($v))
{
//仍是数组,继续
foreach($v as $kk => $vv){
$temp['key'] = $kk; //析取key
$temp['value'] = serialize($vv); //不再往下构造了——三级数组保存式(setfor-title-key=>value)
$newData[] = $temp;
}
}else{
$temp['key'] = $k;
$temp['value'] = serialize($v);
$newData[] = $temp;
}
}
}else{
$temp['title'] = $setfor;
$temp['key'] = $setfor;
$temp['value'] = serialize($value);
$newData[] = $temp;
}
}
break;
case 'attr':
break;
default:
break;
}
return $newData;
}
/*
SQL命令生成
根据参数生成某类表的SQL命令并返回
*/
function get_sql_all($params)
{
global $_FM;
$sqls = array();
$dbPrefix = $params['dbPrefix'];
$tablePrefix = $params['tablePrefix'];
$name = $params['name'];
$tableTitle = $params['tableTitle'];
$type = $params['type'];
$tableTypes = $this->table_suffix();
foreach($tableTypes as $k){
$sqls[$k] = $this->get_sql($dbPrefix,$tablePrefix,$name,$k,$tableTitle,$type);
}
$result = '';
foreach($sqls as $k => $sql){
$columns = $sqls[$k]['columns'];
unset($columns['id']); //将id字段排除(新表创建时自动添加了)
$indexes = $sqls[$k]['indexes'];
unset($indexes['id']); //将id字段排除(新表创建时自动添加了)
$result .= '
';
$result .= $sql = $sqls[$k]['sql'];
//1st 创建字段
foreach($columns as $column){
$result .= '
';
$result .= $column;
}
//2nd 创建索引
foreach($indexes as $index){
$result .= '
';
$result .= $index;
}
}
$sqls = array($result);
return $result;
}
/*
SQL命令生成-返回单表命令集:[sql]-表创建命令(带id字段);[columns]-表字段创建命令集(适用于新建);[indexes]-表索引创建命令集(适用于新建);[changec]-表字段调整命令集(适用于后期维护表-TBD)
@db 目标数据库
@dbPrefix 数据库系统前缀
@tablePrefix 数据表类型前缀
@name 类表名称
@tableType 目标数据表后缀(self,param,form,addon,order,data,attr,pre)
@tableTitle 类表备注/注释
@type 表功能类约定(数组)
*/
function get_sql($dbPrefix,$tablePrefix,$name,$tableType,$tableTitle,$type)
{
$dbPrefix = isset($dbPrefix) ? $dbPrefix : false;
$dbPrefix = ($dbPrefix) ? $dbPrefix.'_' : '';
$tablePrefix = isset($tablePrefix) ? $tablePrefix : false;
$tablePrefix = ($tablePrefix) ? $tablePrefix.'_' : '';
$type = (!is_array($type) || empty($type)) ? array("all") : $type;
if(!isset($name)){
if(FM_DEBUG){
trigger_error('未传入name参数', E_USER_ERROR);
}
return false;
}
if(!isset($tableType)){
if(FM_DEBUG){
trigger_error('未传入tableType参数', E_USER_ERROR);
}
return false;
}
$tableName = $dbPrefix.$tablePrefix.$name.'_'.$tableType;
$tables[$tableName] = array();
$tables[$tableName]['name'] = $tableTitle;
$key = "\$table['".$tableName."']['name']"; //原生成到php文件以便动态调用的方法,带了$table变量名的
$key = "name"; //直接生成固定表名的方法
$sql[$key] = $tables[$tableName]['name'];
$tables[$tableName]['type'] = $type;
$key = "\$table\[\'".$tableName."\'\]\[\'type\'\]";
$key = "type";
$sql[$key] = $tables[$tableName]['type'];
switch($tableType) {
case 'self':
$createsql = "CREATE TABLE IF NOT EXISTS ".$tableName." (`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID', PRIMARY KEY (`id`) USING BTREE) ENGINE=InnoDB CHARSET=utf8 COLLATE utf8_general_ci COMMENT='".$tableTitle."主表' ;";
$columns = array();
$columns['id'] = "ALTER TABLE ".$tableName." ADD `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID' ;";
$columns['sn'] = "ALTER TABLE ".$tableName." ADD `sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '与其他表进行关联的唯一记录编码' ;";
$columns['siteid'] = "ALTER TABLE ".$tableName." ADD `siteid` INT(11) UNSIGNED NOT NULL COMMENT '所属安装站点编码' ;";
$columns['platid'] = "ALTER TABLE ".$tableName." ADD `platid` INT(11) UNSIGNED NOT NULL COMMENT '所属平台编码' ;";
$columns['uniacid'] = "ALTER TABLE ".$tableName." ADD `uniacid` INT(11) UNSIGNED NOT NULL COMMENT '所属公众号编码' ;";
$columns['shopid'] = "ALTER TABLE ".$tableName." ADD `shopid` INT(11) UNSIGNED NOT NULL COMMENT '所属商铺编码' ;";
$columns['title'] = "ALTER TABLE ".$tableName." ADD `title` VARCHAR(255) NOT NULL COMMENT '标题' ;";
$columns['keywords'] = "ALTER TABLE ".$tableName." ADD `keywords` VARCHAR(255) NOT NULL COMMENT '供检索的关键词串' ;";
$columns['displayorder'] = "ALTER TABLE ".$tableName." ADD `displayorder` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序权重' ;";
$columns['status'] = "ALTER TABLE ".$tableName." ADD `status` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '站内状态代码' ;";
$columns['deleted'] = "ALTER TABLE ".$tableName." ADD `deleted` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除(1是0否)' ;";
$columns['createtime'] = "ALTER TABLE ".$tableName." ADD `createtime` INT(11) UNSIGNED NOT NULL COMMENT '记录创建时间' ;";
$columns['updatetime'] = "ALTER TABLE ".$tableName." ADD `updatetime` INT(11) UNSIGNED NOT NULL COMMENT '记录更新时间' ;";
$columns['statuscode'] = "ALTER TABLE ".$tableName." ADD `statuscode` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '全站状态代码(-128~127)' ;";
$columns['update_at'] = "ALTER TABLE ".$tableName." ADD `update_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录更新时间' ;";
$indexes = array();
$index = "`id` (`id`)";
$indexes['id'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`sn` (`sn`)";
$indexes['sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`siteid` (`siteid`)";
$indexes['siteid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`uniacid` (`uniacid`)";
$indexes['uniacid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`shopid` (`shopid`)";
$indexes['shopid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`keywords` (`keywords`)";
$indexes['keywords'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
//$indexes['\/\/'] = "为了提高效率,根据建议,优选6个索引序列,前两个为常用;使用顺序不可更改";
break;
case 'form':
$createsql = "CREATE TABLE IF NOT EXISTS ".$tableName." (`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID', PRIMARY KEY (`id`) USING BTREE) ENGINE=InnoDB CHARSET=utf8 COLLATE utf8_general_ci COMMENT='".$tableTitle."实例表' ;";
$columns = array();
$columns['id'] = "ALTER TABLE ".$tableName." ADD `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID' ;";
$columns['sn'] = "ALTER TABLE ".$tableName." ADD `sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '与其他表进行关联的唯一记录编码' ;";
$columns['s_sn'] = "ALTER TABLE ".$tableName." ADD `s_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应主表的记录编码' ;";
$columns['siteid'] = "ALTER TABLE ".$tableName." ADD `siteid` INT(11) UNSIGNED NOT NULL COMMENT '所属安装站点编码' ;";
$columns['platid'] = "ALTER TABLE ".$tableName." ADD `platid` INT(11) UNSIGNED NOT NULL COMMENT '所属平台编码' ;";
$columns['uniacid'] = "ALTER TABLE ".$tableName." ADD `uniacid` INT(11) UNSIGNED NOT NULL COMMENT '所属公众号编码' ;";
$columns['shopid'] = "ALTER TABLE ".$tableName." ADD `shopid` INT(11) UNSIGNED NOT NULL COMMENT '所属商铺编码' ;";
$columns['partnerid'] = "ALTER TABLE ".$tableName." ADD `partnerid` INT(11) UNSIGNED NOT NULL COMMENT '所属合作商户编码' ;";
$columns['uid'] = "ALTER TABLE ".$tableName." ADD `uid` INT(11) UNSIGNED NOT NULL COMMENT '所属后台用户编码' ;";
$columns['title'] = "ALTER TABLE ".$tableName." ADD `title` VARCHAR(255) NOT NULL COMMENT '标题' ;";
$columns['value'] = "ALTER TABLE ".$tableName." ADD `value` TEXT NOT NULL COMMENT '具体内容或描述' ;";
$columns['displayorder'] = "ALTER TABLE ".$tableName." ADD `displayorder` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序权重' ;";
$columns['status'] = "ALTER TABLE ".$tableName." ADD `status` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '站内状态代码' ;";
$columns['deleted'] = "ALTER TABLE ".$tableName." ADD `deleted` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除(1是0否)' ;";
$columns['createtime'] = "ALTER TABLE ".$tableName." ADD `createtime` INT(11) UNSIGNED NOT NULL COMMENT '记录创建时间' ;";
$columns['updatetime'] = "ALTER TABLE ".$tableName." ADD `updatetime` INT(11) UNSIGNED NOT NULL COMMENT '记录更新时间' ;";
$columns['statuscode'] = "ALTER TABLE ".$tableName." ADD `statuscode` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '全站状态代码(-128~127)' ;";
$columns['update_at'] = "ALTER TABLE ".$tableName." ADD `update_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录更新时间' ;";
$indexes = array();
$index = "`id` (`id`)";
$indexes['id'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`sn` (`sn`)";
$indexes['sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`s_sn` (`s_sn`)";
$indexes['s_sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`siteid` (`siteid`)";
$indexes['siteid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`uniacid` (`uniacid`)";
$indexes['uniacid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`title` (`title`)";
$indexes['title'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
//$indexes['\/\/'] = "为了提高效率,根据建议,优选6个索引序列,前两个为常用;使用顺序不可更改";
break;
case 'param':
$createsql = "CREATE TABLE IF NOT EXISTS ".$tableName." (`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID', PRIMARY KEY (`id`) USING BTREE) ENGINE=MyISAM CHARSET=utf8 COLLATE utf8_general_ci COMMENT='".$tableTitle."主参数表' ;";
$columns = array();
$columns['id'] = "ALTER TABLE ".$tableName." ADD `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID' ;";
$columns['sn'] = "ALTER TABLE ".$tableName." ADD `sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '与其他表进行关联的唯一记录编码' ;";
$columns['s_sn'] = "ALTER TABLE ".$tableName." ADD `s_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应主表的记录编码' ;";
$columns['f_sn'] = "ALTER TABLE ".$tableName." ADD `f_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应实例表的记录编码' ;";
$columns['siteid'] = "ALTER TABLE ".$tableName." ADD `siteid` INT(11) UNSIGNED NOT NULL COMMENT '所属安装站点编码' ;";
$columns['platid'] = "ALTER TABLE ".$tableName." ADD `platid` INT(11) UNSIGNED NOT NULL COMMENT '所属平台编码' ;";
$columns['uniacid'] = "ALTER TABLE ".$tableName." ADD `uniacid` INT(11) UNSIGNED NOT NULL COMMENT '所属公众号编码' ;";
$columns['shopid'] = "ALTER TABLE ".$tableName." ADD `shopid` INT(11) UNSIGNED NOT NULL COMMENT '所属商铺编码' ;";
$columns['partnerid'] = "ALTER TABLE ".$tableName." ADD `partnerid` INT(11) UNSIGNED NOT NULL COMMENT '所属合作商户编码' ;";
$columns['setfor'] = "ALTER TABLE ".$tableName." ADD `setfor` VARCHAR(50) NOT NULL COMMENT '参数归属类别' ;";
$columns['title'] = "ALTER TABLE ".$tableName." ADD `title` VARCHAR(255) NOT NULL COMMENT '参数标题' ;";
$columns['key'] = "ALTER TABLE ".$tableName." ADD `key` VARCHAR(255) NOT NULL COMMENT '参数键值' ;";
$columns['value'] = "ALTER TABLE ".$tableName." ADD `value` TEXT NOT NULL COMMENT '参数具体值' ;";
$columns['displayorder'] = "ALTER TABLE ".$tableName." ADD `displayorder` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序权重' ;";
$columns['status'] = "ALTER TABLE ".$tableName." ADD `status` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '站内状态代码' ;";
$columns['deleted'] = "ALTER TABLE ".$tableName." ADD `deleted` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除(1是0否)' ;";
$columns['createtime'] = "ALTER TABLE ".$tableName." ADD `createtime` INT(11) UNSIGNED NOT NULL COMMENT '记录创建时间' ;";
$columns['updatetime'] = "ALTER TABLE ".$tableName." ADD `updatetime` INT(11) UNSIGNED NOT NULL COMMENT '记录更新时间' ;";
$columns['statuscode'] = "ALTER TABLE ".$tableName." ADD `statuscode` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '全站状态代码(-128~127)' ;";
$columns['update_at'] = "ALTER TABLE ".$tableName." ADD `update_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录更新时间' ;";
$indexes = array();
$index = "`id` (`id`)";
$indexes['id'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`sn` (`sn`)";
$indexes['sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`s_sn` (`s_sn`)";
$indexes['s_sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`setfor` (`setfor`)";
$indexes['setfor'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`title` (`title`)";
$indexes['title'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`key` (`key`)";
$indexes['key'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
//$indexes['\/\/'] = "为了提高效率,根据建议,优选6个索引序列,前两个为常用;使用顺序不可更改";
break;
case 'order':
$createsql = "CREATE TABLE IF NOT EXISTS ".$tableName." (`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID', PRIMARY KEY (`id`) USING BTREE) ENGINE=InnoDB CHARSET=utf8 COLLATE utf8_general_ci COMMENT='".$tableTitle."数据提交/收集表单表' ;";
$columns = array();
$columns['id'] = "ALTER TABLE ".$tableName." ADD `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID' ;";
$columns['sn'] = "ALTER TABLE ".$tableName." ADD `sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '与其他表进行关联的唯一记录编码' ;";
$columns['s_sn'] = "ALTER TABLE ".$tableName." ADD `s_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应主表的记录编码' ;";
$columns['f_sn'] = "ALTER TABLE ".$tableName." ADD `f_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应实例表的记录编码' ;";
$columns['siteid'] = "ALTER TABLE ".$tableName." ADD `siteid` INT(11) UNSIGNED NOT NULL COMMENT '所属安装站点编码' ;";
$columns['platid'] = "ALTER TABLE ".$tableName." ADD `platid` INT(11) UNSIGNED NOT NULL COMMENT '所属平台编码' ;";
$columns['uniacid'] = "ALTER TABLE ".$tableName." ADD `uniacid` INT(11) UNSIGNED NOT NULL COMMENT '所属公众号编码' ;";
$columns['shopid'] = "ALTER TABLE ".$tableName." ADD `shopid` INT(11) UNSIGNED NOT NULL COMMENT '所属商铺编码' ;";
$columns['partnerid'] = "ALTER TABLE ".$tableName." ADD `partnerid` INT(11) UNSIGNED NOT NULL COMMENT '所属合作商户编码' ;";
$columns['mid'] = "ALTER TABLE ".$tableName." ADD `mid` INT(11) UNSIGNED NOT NULL COMMENT '所属前台会员编码' ;";
$columns['fid'] = "ALTER TABLE ".$tableName." ADD `fid` INT(11) UNSIGNED NOT NULL COMMENT '所属前台粉丝(非注册用户)编码' ;";
$columns['title'] = "ALTER TABLE ".$tableName." ADD `title` VARCHAR(255) NOT NULL COMMENT '标题' ;";
$columns['value'] = "ALTER TABLE ".$tableName." ADD `value` TEXT NOT NULL COMMENT '具体内容或描述' ;";
$columns['displayorder'] = "ALTER TABLE ".$tableName." ADD `displayorder` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序权重' ;";
$columns['status'] = "ALTER TABLE ".$tableName." ADD `status` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '站内状态代码' ;";
$columns['deleted'] = "ALTER TABLE ".$tableName." ADD `deleted` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除(1是0否)' ;";
$columns['createtime'] = "ALTER TABLE ".$tableName." ADD `createtime` INT(11) UNSIGNED NOT NULL COMMENT '记录创建时间' ;";
$columns['updatetime'] = "ALTER TABLE ".$tableName." ADD `updatetime` INT(11) UNSIGNED NOT NULL COMMENT '记录更新时间' ;";
$columns['statuscode'] = "ALTER TABLE ".$tableName." ADD `statuscode` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '全站状态代码(-128~127)' ;";
$columns['update_at'] = "ALTER TABLE ".$tableName." ADD `update_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录更新时间' ;";
$indexes = array();
$indexes['siteid']="`siteid` (`siteid`)";
$indexes['uniacid']="`uniacid` (`uniacid`)";
$index = "`id` (`id`)";
$indexes['id'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`sn` (`sn`)";
$indexes['sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`s_sn` (`s_sn`)";
$indexes['s_sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`f_sn` (`f_sn`)";
$indexes['f_sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`siteid` (`siteid`)";
$indexes['siteid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`uniacid` (`uniacid`)";
$indexes['uniacid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
//$indexes['\/\/'] = "为了提高效率,根据建议,优选6个索引序列,前两个为常用;使用顺序不可更改";
break;
case 'addon':
$createsql = "CREATE TABLE IF NOT EXISTS ".$tableName." (`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID', PRIMARY KEY (`id`) USING BTREE) ENGINE=MyISAM CHARSET=utf8 COLLATE utf8_general_ci COMMENT='".$tableTitle."附加参数表' ;";
$columns = array();
$columns['id'] = "ALTER TABLE ".$tableName." ADD `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID' ;";
$columns['sn'] = "ALTER TABLE ".$tableName." ADD `sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '与其他表进行关联的唯一记录编码' ;";
$columns['s_sn'] = "ALTER TABLE ".$tableName." ADD `s_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应主表的记录编码' ;";
$columns['f_sn'] = "ALTER TABLE ".$tableName." ADD `f_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应实例表的记录编码' ;";
$columns['o_sn'] = "ALTER TABLE ".$tableName." ADD `o_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应数据提交表单的记录编码' ;";
$columns['siteid'] = "ALTER TABLE ".$tableName." ADD `siteid` INT(11) UNSIGNED NOT NULL COMMENT '所属安装站点编码' ;";
$columns['platid'] = "ALTER TABLE ".$tableName." ADD `platid` INT(11) UNSIGNED NOT NULL COMMENT '所属平台编码' ;";
$columns['uniacid'] = "ALTER TABLE ".$tableName." ADD `uniacid` INT(11) UNSIGNED NOT NULL COMMENT '所属公众号编码' ;";
$columns['shopid'] = "ALTER TABLE ".$tableName." ADD `shopid` INT(11) UNSIGNED NOT NULL COMMENT '所属商铺编码' ;";
$columns['partnerid'] = "ALTER TABLE ".$tableName." ADD `partnerid` INT(11) UNSIGNED NOT NULL COMMENT '所属合作商户编码' ;";
$columns['mid'] = "ALTER TABLE ".$tableName." ADD `mid` INT(11) UNSIGNED NOT NULL COMMENT '所属前台会员编码' ;";
$columns['fid'] = "ALTER TABLE ".$tableName." ADD `fid` INT(11) UNSIGNED NOT NULL COMMENT '所属前台粉丝(非注册用户)编码' ;";
$columns['setfor'] = "ALTER TABLE ".$tableName." ADD `setfor` VARCHAR(50) NOT NULL COMMENT '参数归属类别' ;";
$columns['title'] = "ALTER TABLE ".$tableName." ADD `title` VARCHAR(255) NOT NULL COMMENT '参数标题' ;";
$columns['key'] = "ALTER TABLE ".$tableName." ADD `key` VARCHAR(255) NOT NULL COMMENT '参数键值' ;";
$columns['value'] = "ALTER TABLE ".$tableName." ADD `value` TEXT NOT NULL COMMENT '参数具体值' ;";
$columns['displayorder'] = "ALTER TABLE ".$tableName." ADD `displayorder` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序权重' ;";
$columns['status'] = "ALTER TABLE ".$tableName." ADD `status` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '站内状态代码' ;";
$columns['deleted'] = "ALTER TABLE ".$tableName." ADD `deleted` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除(1是0否)' ;";
$columns['createtime'] = "ALTER TABLE ".$tableName." ADD `createtime` INT(11) UNSIGNED NOT NULL COMMENT '记录创建时间' ;";
$columns['updatetime'] = "ALTER TABLE ".$tableName." ADD `updatetime` INT(11) UNSIGNED NOT NULL COMMENT '记录更新时间' ;";
$columns['statuscode'] = "ALTER TABLE ".$tableName." ADD `statuscode` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '全站状态代码(-128~127)' ;";
$columns['update_at'] = "ALTER TABLE ".$tableName." ADD `update_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录更新时间' ;";
$indexes = array();
$index = "`id` (`id`)";
$indexes['id'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`sn` (`sn`)";
$indexes['sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`o_sn` (`o_sn`)";
$indexes['o_sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`setfor` (`setfor`)";
$indexes['setfor'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`title` (`title`)";
$indexes['title'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`key` (`key`)";
$indexes['key'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
//$indexes['\/\/'] = "为了提高效率,根据建议,优选6个索引序列,前两个为常用;使用顺序不可更改";
break;
case 'data':
$createsql = "CREATE TABLE IF NOT EXISTS ".$tableName." (`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID', PRIMARY KEY (`id`) USING BTREE) ENGINE=MyISAM CHARSET=utf8 COLLATE utf8_general_ci COMMENT='".$tableTitle."具体数据表' ;";
$columns = array();
$columns['id'] = "ALTER TABLE ".$tableName." ADD `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID' ;";
$columns['sn'] = "ALTER TABLE ".$tableName." ADD `sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '与其他表进行关联的唯一记录编码' ;";
$columns['s_sn'] = "ALTER TABLE ".$tableName." ADD `s_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应主表的记录编码' ;";
$columns['f_sn'] = "ALTER TABLE ".$tableName." ADD `f_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应实例表的记录编码' ;";
$columns['o_sn'] = "ALTER TABLE ".$tableName." ADD `o_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应数据提交表单的记录编码' ;";
$columns['siteid'] = "ALTER TABLE ".$tableName." ADD `siteid` INT(11) UNSIGNED NOT NULL COMMENT '所属安装站点编码' ;";
$columns['platid'] = "ALTER TABLE ".$tableName." ADD `platid` INT(11) UNSIGNED NOT NULL COMMENT '所属平台编码' ;";
$columns['uniacid'] = "ALTER TABLE ".$tableName." ADD `uniacid` INT(11) UNSIGNED NOT NULL COMMENT '所属公众号编码' ;";
$columns['shopid'] = "ALTER TABLE ".$tableName." ADD `shopid` INT(11) UNSIGNED NOT NULL COMMENT '所属商铺编码' ;";
$columns['partnerid'] = "ALTER TABLE ".$tableName." ADD `partnerid` INT(11) UNSIGNED NOT NULL COMMENT '所属合作商户编码' ;";
$columns['mid'] = "ALTER TABLE ".$tableName." ADD `mid` INT(11) UNSIGNED NOT NULL COMMENT '所属前台会员编码' ;";
$columns['fid'] = "ALTER TABLE ".$tableName." ADD `fid` INT(11) UNSIGNED NOT NULL COMMENT '所属前台粉丝(非注册用户)编码' ;";
$columns['setfor'] = "ALTER TABLE ".$tableName." ADD `setfor` VARCHAR(50) NOT NULL COMMENT '参数归属类别' ;";
$columns['title'] = "ALTER TABLE ".$tableName." ADD `title` VARCHAR(255) NOT NULL COMMENT '参数标题' ;";
$columns['key'] = "ALTER TABLE ".$tableName." ADD `key` VARCHAR(255) NOT NULL COMMENT '参数键值' ;";
$columns['value'] = "ALTER TABLE ".$tableName." ADD `value` TEXT NOT NULL COMMENT '参数具体值' ;";
$columns['displayorder'] = "ALTER TABLE ".$tableName." ADD `displayorder` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序权重' ;";
$columns['status'] = "ALTER TABLE ".$tableName." ADD `status` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '站内状态代码' ;";
$columns['deleted'] = "ALTER TABLE ".$tableName." ADD `deleted` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除(1是0否)' ;";
$columns['createtime'] = "ALTER TABLE ".$tableName." ADD `createtime` INT(11) UNSIGNED NOT NULL COMMENT '记录创建时间' ;";
$columns['updatetime'] = "ALTER TABLE ".$tableName." ADD `updatetime` INT(11) UNSIGNED NOT NULL COMMENT '记录更新时间' ;";
$columns['statuscode'] = "ALTER TABLE ".$tableName." ADD `statuscode` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '全站状态代码(-128~127)' ;";
$columns['update_at'] = "ALTER TABLE ".$tableName." ADD `update_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录更新时间' ;";
$indexes = array();
$index = "`id` (`id`)";
$indexes['id'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`sn` (`sn`)";
$indexes['sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`o_sn` (`o_sn`)";
$indexes['o_sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`mid` (`mid`)";
$indexes['mid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`setfor` (`setfor`)";
$indexes['setfor'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`title` (`title`)";
$indexes['title'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`key` (`key`)";
$indexes['key'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
//$indexes['\/\/'] = "为了提高效率,根据建议,优选6个索引序列,前两个为常用;使用顺序不可更改";
break;
case 'attr':
$createsql = "CREATE TABLE IF NOT EXISTS ".$tableName." (`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID', PRIMARY KEY (`id`) USING BTREE) ENGINE=MyISAM CHARSET=utf8 COLLATE utf8_general_ci COMMENT='".$tableTitle."数据属性微调表' ;";
$columns = array();
$columns['id'] = "ALTER TABLE ".$tableName." ADD `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID' ;";
$columns['sn'] = "ALTER TABLE ".$tableName." ADD `sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '与其他表进行关联的唯一记录编码' ;";
$columns['t_sn'] = "ALTER TABLE ".$tableName." ADD `t_sn` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应数据表的记录编码' ;";
$columns['siteid'] = "ALTER TABLE ".$tableName." ADD `siteid` INT(11) UNSIGNED NOT NULL COMMENT '所属安装站点编码' ;";
$columns['platid'] = "ALTER TABLE ".$tableName." ADD `platid` INT(11) UNSIGNED NOT NULL COMMENT '所属平台编码' ;";
$columns['uniacid'] = "ALTER TABLE ".$tableName." ADD `uniacid` INT(11) UNSIGNED NOT NULL COMMENT '所属公众号编码' ;";
$columns['shopid'] = "ALTER TABLE ".$tableName." ADD `shopid` INT(11) UNSIGNED NOT NULL COMMENT '所属商铺编码' ;";
$columns['partnerid'] = "ALTER TABLE ".$tableName." ADD `partnerid` INT(11) UNSIGNED NOT NULL COMMENT '所属合作商户编码' ;";
$columns['uid'] = "ALTER TABLE ".$tableName." ADD `uid` INT(11) UNSIGNED NOT NULL COMMENT '所属后台会员编码' ;";
$columns['mid'] = "ALTER TABLE ".$tableName." ADD `mid` INT(11) UNSIGNED NOT NULL COMMENT '所属前台会员编码' ;";
$columns['fid'] = "ALTER TABLE ".$tableName." ADD `fid` INT(11) UNSIGNED NOT NULL COMMENT '所属前台粉丝(非注册用户)编码' ;";
$columns['suffix'] = "ALTER TABLE ".$tableName." ADD `suffix` VARCHAR(50) NOT NULL COMMENT '对应表后缀(用于区分表)' ;";
$columns['setfor'] = "ALTER TABLE ".$tableName." ADD `setfor` VARCHAR(50) NOT NULL COMMENT '参数归属类别' ;";
$columns['title'] = "ALTER TABLE ".$tableName." ADD `title` VARCHAR(255) NOT NULL COMMENT '参数标题' ;";
$columns['key'] = "ALTER TABLE ".$tableName." ADD `key` VARCHAR(255) NOT NULL COMMENT '参数键值' ;";
$columns['value'] = "ALTER TABLE ".$tableName." ADD `value` TEXT NOT NULL COMMENT '参数具体值' ;";
$columns['displayorder'] = "ALTER TABLE ".$tableName." ADD `displayorder` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序权重' ;";
$columns['status'] = "ALTER TABLE ".$tableName." ADD `status` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '站内状态代码' ;";
$columns['deleted'] = "ALTER TABLE ".$tableName." ADD `deleted` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除(1是0否)' ;";
$columns['createtime'] = "ALTER TABLE ".$tableName." ADD `createtime` INT(11) UNSIGNED NOT NULL COMMENT '记录创建时间' ;";
$columns['updatetime'] = "ALTER TABLE ".$tableName." ADD `updatetime` INT(11) UNSIGNED NOT NULL COMMENT '记录更新时间' ;";
$columns['statuscode'] = "ALTER TABLE ".$tableName." ADD `statuscode` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '全站状态代码(-128~127)' ;";
$columns['update_at'] = "ALTER TABLE ".$tableName." ADD `update_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录更新时间' ;";
$indexes = array();
$index = "`id` (`id`)";
$indexes['id'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`sn` (`sn`)";
$indexes['sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`t_sn` (`t_sn`)";
$indexes['t_sn'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`uid` (`uid`)";
$indexes['uid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`mid` (`mid`)";
$indexes['mid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`setfor` (`setfor`)";
$indexes['setfor'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
//$indexes['\/\/'] = "为了提高效率,根据建议,优选6个索引序列,前两个为常用;使用顺序不可更改";
break;
case 'pre':
$createsql = "CREATE TABLE IF NOT EXISTS ".$tableName." (`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID', PRIMARY KEY (`id`) USING BTREE) ENGINE=MyISAM CHARSET=utf8 COLLATE utf8_general_ci COMMENT='".$tableTitle."数据表预编辑操作记录' ;";
$columns = array();
$columns['id'] = "ALTER TABLE ".$tableName." ADD `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '表记录序号ID' ;";
$columns['tid'] = "ALTER TABLE ".$tableName." ADD `tid` BIGINT(20) UNSIGNED NOT NULL COMMENT '对应数据表的记录id' ;";
$columns['siteid'] = "ALTER TABLE ".$tableName." ADD `siteid` INT(11) UNSIGNED NOT NULL COMMENT '所属安装站点编码' ;";
$columns['uniacid'] = "ALTER TABLE ".$tableName." ADD `uniacid` INT(11) UNSIGNED NOT NULL COMMENT '所属公众号编码' ;";
$columns['uid'] = "ALTER TABLE ".$tableName." ADD `uid` INT(11) UNSIGNED NOT NULL COMMENT '操作者所属后台会员编码' ;";
$columns['mid'] = "ALTER TABLE ".$tableName." ADD `mid` INT(11) UNSIGNED NOT NULL COMMENT '操作者所属前台会员编码' ;";
$columns['fid'] = "ALTER TABLE ".$tableName." ADD `fid` INT(11) UNSIGNED NOT NULL COMMENT '操作者所属前台粉丝(非注册用户)编码' ;";
$columns['suffix'] = "ALTER TABLE ".$tableName." ADD `suffix` VARCHAR(50) NOT NULL COMMENT '对应表后缀(用于区分表)' ;";
$columns['setfor'] = "ALTER TABLE ".$tableName." ADD `setfor` VARCHAR(50) NOT NULL COMMENT '对应字段' ;";
$columns['value'] = "ALTER TABLE ".$tableName." ADD `value` TEXT NOT NULL COMMENT '参数具体值' ;";
$columns['status'] = "ALTER TABLE ".$tableName." ADD `status` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '站内状态代码' ;";
$columns['deleted'] = "ALTER TABLE ".$tableName." ADD `deleted` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除(1是0否)' ;";
$columns['createtime'] = "ALTER TABLE ".$tableName." ADD `createtime` INT(11) UNSIGNED NOT NULL COMMENT '记录创建时间' ;";
$columns['statuscode'] = "ALTER TABLE ".$tableName." ADD `statuscode` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '全站状态代码(-128~127)' ;";
$columns['create_at'] = "ALTER TABLE ".$tableName." ADD `create_at`TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录更新时间' ;";
$indexes = array();
$index = "`id` (`id`)";
$indexes['id'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`tid` (`tid`)";
$indexes['tid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`uid` (`uid`)";
$indexes['uid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`mid` (`mid`)";
$indexes['mid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`siteid` (`siteid`)";
$indexes['siteid'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
$index = "`setfor` (`setfor`)";
$indexes['setfor'] = "ALTER TABLE ".$tableName." ADD INDEX".$index.";";
//$indexes['\/\/'] = "为了提高效率,根据建议,优选6个索引序列,前两个为常用;使用顺序不可更改";
break;
default:
break;
}
$tables[$tableName]['sql'] = $createsql;
$key = "\$table\[\'".$tableName."\'\]\[\'sql\'\]";
$key = "sql";
$sql[$key] = $tables[$tableName]['sql'];
$key = "\$table\[\'".$tableName."\'\]\[\'columns\'\]";
$key = "columns";
$sql[$key] = $columns;
$key = "\$table\[\'".$tableName."\'\]\[\'indexes\'\]";
$key = "indexes";
$sql[$key] = $indexes;
return $sql;
}
}