thinkphp中的模型是什么?

2022-07-2410:11:52后端程序开发Comments1,080 views字数 642阅读模式

thinkphp中的模型是什么?文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

本文操作环境:Windows10系统、ThinkPHP5版、Dell G3电脑。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

thinkphp中的模型是什么

模型(Model)是 ThinkPHP 中一个很重要的概念,与之有关的还包括模型的定义与实例化。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

MVC 是一种将应用程序的逻辑层和表现层进行分离的方法,ThinkPHP 也是基于MVC设计模式的。ThinkPHP 中模型(M)的定义是由 Model 类来完成的。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

ThinkPHP 中基础的模型类就是 Model 类,该类完成了基本的 CURD、ActiveRecord 模式、连贯操作和统计查询等。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

1、什么是模型(Model)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

模型表示企业数据和业务规则,实际项目开发中,主要实现与数据库进行操作。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

2、模型的定义规则文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

模型类的命名规则是除去表前缀的数据表名称,采用驼峰法命名,并且首字母大写,然后加上模型类的关键词Model,再加上类文件后缀.class.php文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

案例:实现移动办公自动化系统的组织结构功能文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

1.设计数据库db_think文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

2.设计数据表结构(tk_dept)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

thinkphp中的模型是什么?文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

3. 使用SQL语句创建数据表文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

thinkphp中的模型是什么?文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

4.创建一个Dept控制器文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

thinkphp中的模型是什么?文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

5.导入add.html模板到./Application/Admin/View/Dept文件夹下文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

6.更改add.html页面中的images/css/js路径信息文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

7.更改办公系统左侧导航链接,要用到的知识点:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

U方法文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

主要功能:用于生成导航链接,如/index.php/Admin/Dept/add,使用方法如下文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

thinkphp中的模型是什么?文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

在实际项目开发中我们通常使用第三种方式,U('模块/控制器/操作方法')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

thinkphp中的模型是什么?文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/25867.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/bc/25867.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定