假设我们有这段代码
count()函数的结果是关于每个查询或查询后的结果 执行 then count 函数返回结果?
$model=Model::query()
foreach ($Entities as $entity) {
$model->orWhereBetween("id",$entity->first_id,$entity->last_id])
}
$model->count()
最佳答案
$model=Model::query()
foreach ($Entities as $entity) {
$model->orWhereBetween("id",$entity->first_id,$entity->last_id])
}
//$model - object of query builder
$model->count();
它将生成一个查询并在数据库端进行计算:SELECT COUNT(*) FROM table WHERE id BETWEEN ?和 ?或 id 之间?和 ?或 id 之间?和?
关于php - Laravel 中的计数函数机制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56303457/