Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent
Last updated 1 year ago.
0

where needs two parameters, and you have only one. Use whereRaw instead.

Last updated 1 year ago.
0

Thx, never though that this would be the issue. So one var in the ->where results in is null.

Last updated 1 year ago.
0

The where() method is used in the form where($column, $operator, $value), so for example where('reputation', '>', 10). If you're using the equals operator, you can just provide two arguments, e.g. where('user_id', 4).

Looking at the API for the method: https://github.com/laravel/framework/blob/4.2/src/Illuminate/D..., if you just provide column, the operator and value default to null. Further down in the method, there's a check to see if the value is null and converts the query into a proper "is null" condition (since using "field = null" won't work), so that seems consistent with the behaviour you are seeing.

So, as above, use whereRaw() since you want to perform a raw where query specific to the DBMS you're using, rather than the abstracted query builder.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.