ThinkCMF应用开发(二)数据表创建

按照上文所述的思路,我们先创建五个表,创建方式按照CMF5定义的规范来,当然你也可以完全自定义

官方表名推荐是“表前缀 _ 应用名 _ 表名”,所以我们按照这样的格式来。

sjb.png

我知道下面这一大段,对于初学者而言有点难,不过还是建议看一看,越是了解,操作起来越是灵活。

当然,程序嘛,实用为主。插件传送门:创建数据表_ThinkCMF插件

这个插件,可以自动创建应用需要的数据表。

表结构

cmf_product_category(表前缀为cmf)

cmf_product_category.png

-- ----------------------------
-- 表结构 cmf_product_category
-- ----------------------------
DROP TABLE IF EXISTS `cmf_product_category`;
CREATE TABLE `cmf_product_category` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '分类ID',
  `parent_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '分类父ID',
  `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '分类名称',
  `description` varchar(255) NOT NULL COMMENT '分类表述',
  `path` varchar(255) NOT NULL DEFAULT '' COMMENT '分类层级关系路径',
  `seo_title` varchar(100) NOT NULL DEFAULT '' COMMENT 'seo标题',
  `seo_keywords` varchar(255) NOT NULL DEFAULT '' COMMENT 'seo关键词',
  `seo_description` varchar(255) NOT NULL DEFAULT '' COMMENT 'seo描述',
  `list_order` float NOT NULL DEFAULT '10000' COMMENT '排序',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态,1:发布,0:不发布',
  `delete_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
  `list_tpl` varchar(50) NOT NULL DEFAULT '' COMMENT '列表页模板文件',
  `detail_tpl` varchar(50) NOT NULL DEFAULT '' COMMENT '详细页模板文件',
  `more` text COMMENT '扩展属性',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4;


cmf_product_category_post(表前缀为cmf)

微信图片_20181206141454.png

-- ----------------------------
-- 表结构 cmf_product_category_post
-- ----------------------------
DROP TABLE IF EXISTS `cmf_product_category_post`;
CREATE TABLE `cmf_product_category_post` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '文章id',
  `category_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '分类id',
  `list_order` float NOT NULL DEFAULT '10000' COMMENT '排序',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态,1:发布;0:不发布',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='portal应用 分类文章对应表';


cmf_product_post(表前缀为cmf)

1.png

-- ----------------------------
-- 表结构 cmf_product_post
-- ----------------------------
DROP TABLE IF EXISTS `cmf_product_post`;
CREATE TABLE `cmf_product_post` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `user_id` bigint(20) unsigned NOT NULL COMMENT '作者ID',
  `post_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'post标题',
  `post_keywords` varchar(150) NOT NULL DEFAULT '' COMMENT '关键词',
  `post_description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述',
  `post_excerpt` text COMMENT '摘要',
  `post_content` text COMMENT '文章内容',
  `post_content_filtered` text COMMENT '处理过的文章内容',
  `post_source` varchar(150) NOT NULL DEFAULT '' COMMENT '转载文章的来源',
  `post_hits` bigint(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '查看数',
  `post_like` bigint(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '点赞数',
  `comment_count` bigint(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '评论数',
  `comment_status` tinyint(3) UNSIGNED NOT NULL DEFAULT '1' COMMENT '评论状态;1:允许;0:不允许',
  `post_status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态;1:已发布;0:未发布;',
  `is_top` tinyint(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否置顶;1:置顶;0:不置顶',
  `recommended` tinyint(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否推荐;1:推荐;0:不推荐',
  `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
  `delete_time` int(10) NOT NULL DEFAULT '0' COMMENT '删除时间',
  `thumbnail` varchar(100) NOT NULL DEFAULT '' COMMENT '缩略图',
  `template` varchar(50) NOT NULL DEFAULT '' COMMENT '页面模板',
  `more` text COMMENT '扩展属性,如缩略图;格式为json',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;


cmf_product_tag(表前缀为cmf)

2.png

-- ----------------------------
-- 表结构 cmf_product_tag
-- ----------------------------
DROP TABLE IF EXISTS `cmf_product_tag`;
CREATE TABLE `cmf_product_tag` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '分类id',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态,1:发布,0:不发布',
  `recommended` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否推荐;1:推荐;0:不推荐',
  `post_count` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '标签文章数',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '标签名称',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='portal应用 文章标签表';


cmf_product_tag_post(表前缀为cmf)

3.png

-- ----------------------------
-- 表结构 cmf_product_tag_post
-- ----------------------------
DROP TABLE IF EXISTS `cmf_product_tag_post`;
CREATE TABLE `cmf_product_tag_post` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `tag_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '标签 id',
  `post_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '文章 id',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态,1:发布;0:不发布',
  PRIMARY KEY (`id`),
  KEY `term_taxonomy_id` (`post_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='portal应用 标签文章对应表';

Comments 0

0.162948s