We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hey,
Let's say that I've got following code:
$users = User::select(['users.id']) ->leftJoin('posts', 'users.id', '=', 'posts.author_id') ->skip(15) ->take(15) ->get();
And I want to count all available rows (ignoring the limit) so I want to add SQL_CALC_FOUND_ROWS. However when I add it to the select:
$users = User::select([DB::raw('SQL_CALC_FOUND_ROWS'), 'users.id']) ->leftJoin('posts', 'users.id', '=', 'posts.author_id') ->skip(15) ->take(15) ->get();
Laravel adds "," between columns so it ends with invalid query. Is there any way to mix SQL_CALC_FOUND_ROWS with selected columns? Please advice.
I know that I could use just count statement. But in this specific example I'd rather use SQL_CALC_FOUND_ROWS.
Thanks!
The text was updated successfully, but these errors were encountered:
This?
$users = User::select([DB::raw('SQL_CALC_FOUND_ROWS users.id')]) ->leftJoin('posts', 'users.id', '=', 'posts.author_id') ->skip(15) ->take(15) ->get();
Sorry, something went wrong.
Well... KISS. That's a good approach, however I thought that there is a "cleaner" way to do it :) Anyway, thanks! That worked of course.
No branches or pull requests
Hey,
Let's say that I've got following code:
And I want to count all available rows (ignoring the limit) so I want to add SQL_CALC_FOUND_ROWS. However when I add it to the select:
Laravel adds "," between columns so it ends with invalid query. Is there any way to mix SQL_CALC_FOUND_ROWS with selected columns? Please advice.
I know that I could use just count statement. But in this specific example I'd rather use SQL_CALC_FOUND_ROWS.
Thanks!
The text was updated successfully, but these errors were encountered: