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

SQLSTATE[HY000]: General error: 2031 for join query with 'where' #185

Open
tony-was opened this issue Dec 31, 2014 · 3 comments
Open

SQLSTATE[HY000]: General error: 2031 for join query with 'where' #185

tony-was opened this issue Dec 31, 2014 · 3 comments
Labels

Comments

@tony-was
Copy link

I ahve the following code snippet:

->leftJoin('blocked_users', function($join) use ($user_id, $id)
{
$join->on('users.id', '=', 'blocked_users.blocked_user_id')
->where('blocked_users.user_id', '=', $user_id);
})

which throws the errors

SQLSTATE[HY000]: General error: 2031 (SQL: select count(*) as aggregate from...

not sure if anyone else is experiencing this.

@CarterZhou
Copy link

Try to use Eloquent in a simpler way?

->leftJoin('blocked_users', 'blocked_users.blocked_user_id','=',$user_id)

And I don't think it is a problem of bllim/laravel4-datatables-package. I would suggest you check Laravel documentation for more details.

@tony-was
Copy link
Author

tony-was commented Jan 3, 2015

@CarterZhou If I run that it gives me an "Unknown Column" error as the last attribute needs to be a column name and not an actual value.

Though I think you are right I will need to re factor this to make it a little cleaner

@brunoerg
Copy link

Try it:

        'options'   => [
            \PDO::ATTR_EMULATE_PREPARES => true
        ] 

Put it on your database config if you are using mysql

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

No branches or pull requests

4 participants