Skip to content

Commit

Permalink
improve performance code
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulrhmansouda committed Apr 11, 2024
1 parent 2a3ab60 commit cecf821
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/QueryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function prepareCountQuery(): QueryBuilder
}

$row_count = $this->wrap('row_count');
$builder->select($this->getConnection()->raw("'1' as {$row_count}"));
$builder->select($this->getConnection()->raw("'1' as {$row_count}"))->reorder();
if (! $this->keepSelectBindings) {
$builder->setBindings([], 'select');
}
Expand All @@ -205,8 +205,9 @@ public function prepareCountQuery(): QueryBuilder
*/
protected function isComplexQuery($query): bool
{

return Str::contains(Str::lower($query->toSql()), ['union', 'having', 'distinct', 'order by', 'group by']);
$queryCheck = (clone $query)->select(DB::raw('1 AS dt_row_count'));

return Str::contains(Str::lower($queryCheck->toSql()), ['union', 'having', 'distinct', 'group by']);
}

/**
Expand Down

0 comments on commit cecf821

Please sign in to comment.