现在有两种方式从Laravel数据库中获取。我想知道哪个更有效。,哪一个得到计数vs没有计数更有效率?
1.获取具有计数
$cnt = \App\Models\Res_Times::where(...)
->count();
if ($cnt > 0) {
$result = \App\Models\Res_Times::where(...)
->get();
}
2.获得直接
$result = \App\Models\Res_Times::where(...)
->get();
我不知道PHP MySQL的计数功能是如此之快值得使用。
请让我知道。
得益于MIMO,CAN你详细解释一下吗? – Alex