上一页 1 2 3 4 5 6 7 ··· 39 下一页

2024年1月24日

摘要: 方法一 验证器的使用 单独抽离成一个文件 declare (strict_types = 1); namespace app\validate; use think\Validate; class ValidateAll extends Validate { /** * 定义验证规则 * 格式:'字 阅读全文
posted @ 2024-01-24 22:51 完美前端 阅读(141) 评论(0) 推荐(0)
摘要: 资源路由 use think\facade\Route; // 资源路由 thinkphp提供了一个命令 方便开发者快速生成一个资源控制器 // 执行 php think make:controller Blog Blog是控制器类文件名字 // 标识 index 类型 get 路由 blog // 阅读全文
posted @ 2024-01-24 20:17 完美前端 阅读(54) 评论(0) 推荐(0)
摘要: 路由分组 route/app.php // 路由分组 相同规则的路由方一起分组 // Route::group('blog', function () { // Route::rule(':id', 'blog/index'); // Route::rule('index', 'blog/login 阅读全文
posted @ 2024-01-24 19:00 完美前端 阅读(46) 评论(0) 推荐(0)
摘要: 路由的使用 在route/app.php文件里设置路由 use think\facade\Route; // rule() // 还有其他的快捷方式 Route::GET POST PUT DELETE PATCH HEAD OPTIONS ANY // Route::rule('index/:id 阅读全文
posted @ 2024-01-24 17:49 完美前端 阅读(208) 评论(0) 推荐(0)
摘要: 多对多的查询 常见场景是权限控制, 一个用户有多个身份, 一个身份可以给多个用户. users 模块 和其他模块 namespace app\model; use think\Model; class Users extends Model { public function role() { re 阅读全文
posted @ 2024-01-24 01:51 完美前端 阅读(287) 评论(0) 推荐(0)
摘要: 模型预载入查询 筛选 统计 模型里 public function profile() { return $this->hasMany(Profile::class); } 使用的地方 类里 public function index() { // 普通查询 有多少条数据 foreach就会获取多少 阅读全文
posted @ 2024-01-24 00:07 完美前端 阅读(63) 评论(0) 推荐(0)

2024年1月23日

摘要: 一对多关联查询 namespace app\model; use think\Model; class Users extends Model { // 模型中定义一对多关系的方法 用于建立当前模型与另一个模型之间的关系, 例如: 当前数据表对应的外键表 // profile 自定义方法名 Prof 阅读全文
posted @ 2024-01-23 22:46 完美前端 阅读(298) 评论(0) 推荐(0)

2024年1月21日

摘要: 一对一关系查询 users主表 namespace app\model; use think\Model; class Users extends Model { // 模型中定义一对一关系的方法 用于建立当前模型与另一个模型之间的关系, 例如: 当前数据表对应的外键表 // profile 自定义 阅读全文
posted @ 2024-01-21 02:15 完美前端 阅读(182) 评论(0) 推荐(0)

2024年1月19日

摘要: 关联模型 namespace app\model; use think\Model; class Users extends Model { // 模型中定义一对一关系的方法 用于建立当前模型与另一个模型之间的关系, 例如: 当前数据表对应的外键表 // abc 自定义方法名 Profile::cl 阅读全文
posted @ 2024-01-19 03:23 完美前端 阅读(21) 评论(0) 推荐(0)
摘要: 数据表 添加外键失败 SQL错误(1452):Cannot add or update a child row: a foreign key constraint 1, 表里已存在的值和关联表不匹配,如表里id为10,关联表没有10 阅读全文
posted @ 2024-01-19 02:44 完美前端 阅读(6) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 39 下一页

导航