Skip to content
New issue

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

[5.8] Query Builder Paginate gives Syntax error if you pass columns into paginate() #28889

Closed
wants to merge 1 commit into from

Conversation

awais-vteams
Copy link
Contributor

  • Laravel Version: 5.8.22
  • PHP Version: 7.2.17
  • Database Driver & Version: MySql 8.0

Description:

Database Query Builder Paginate gives SQLSTATE[42000]: Syntax error if you pass columns into paginate()

Steps To Reproduce:

$results = DB::table('users')->paginate(20, ['id', 'name']);

Illuminate \ Database \ QueryException (42000)
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' name) as aggregate from users' at line 1 (SQL: select count(id, name) as aggregate from users)

I think that's why you didn't pass $columns in Illuminate/Database/Eloquent/Builder::paginate()

image

@taylorotwell
Copy link
Member

Please review previously closed PRs.

@driesvints
Copy link
Member

@awais-vteams I've resubmitted this here with some tests and a more thorough explanation of the problem at hand: #28937

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants