2023年12月

1、入口:index.php

入口文件中,调用模块:

// 定义为入口文件
define('IS_INDEX', true);

// 入口文件地址绑定
define('URL_BIND', 'index');

URL_BIND即为调用的模块名

2、模块

模块在 /apps/目录下,以目录名作为模块名,默认的有 admin, api, home

每个模块根据需要可以有 config/, controller/, model/, view/ 等目录。分别用于配置,控制器,数据库,模板 等等操作。

3、URL路由

入口文件中,一般 p参数用于定义URL路由,如:

index.php?p=/login/authenticate&redirect_url=…..

上述url,将调用 controller/LoginController::authenticate()方法进行处理。

4、参数获取:

全局方法: get(), post()

重定向: location($url)

5、数据库操作Modal

  1. 继承 core\basic\Modal
  2. 表名: Modal::$table
  3. 主键: Modal::$pk (默认$id)
  4. 插入: Model::insert(array $row) 插入一行
  5. 查找: Model::where(array $condition)->select() [或find()] $condition里面是多个条件,AND操作,比如["id>1", "username='hehe'" ]
  6. 更新: Model::update(array $data), 先用where()找到需要更新的记录,然后调用update(),更新字段;
  7. 递增: Model::setInc($field) , 先用where()找到需要更新的记录,然后调用setInc(字段)对该字段做+1操作。