sch*_*4ok 5 eager-loading laravel eloquent
当我在 Laravel 7.2.0 中执行这段代码时
$news = NewsPost::select('title','slug','category_id', 'image', 'fulltext', 'created_at')->with('category:id,title,slug')->orderBy('created_at', 'desc')->simplePaginate(10);
Run Code Online (Sandbox Code Playgroud)
我页面上有 3 个查询
select `title`, `slug`, `category_id`, `image`, `fulltext`, `created_at` from `news_posts` where `news_posts`.`deleted_at` is null order by `created_at` desc limit 11 offset 0
select `id`, `title`, `slug` from `news_categories` where `news_categories`.`id` in (2, 4)
select * from `news_categories` where 0 = 1
Run Code Online (Sandbox Code Playgroud)
我无法理解上次查询的目的是什么以及意味着什么where 0 = 1
| 归档时间: |
|
| 查看次数: |
1410 次 |
| 最近记录: |