So I have a query that, on my production installation requires quotations around "id" in the 'where' method, otherwise returns no results. On my local installation, the exact opposite is happening. If I'm using quotations, it's not functioning.
Production
'invoices' => Auth::user()->invoices->where('paid', "0")
Localhost
'invoices' => Auth::user()->invoices->where('paid', 0)
It's really strange, and I'd really like to not have go in and change this whenever I deploy from github. Is this a common issue? I can't seem to find anything about it.
I'll list some Laravel query logs:
Local install with quotations around the int (not working)
Array (
[0] => Array (
[query] => select * from `users` where `users`.`id` = ? limit 1
[bindings] => Array (
[0] => 1
)
[time] => 10.49
)
[1] => Array (
[query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
[bindings] => Array (
[0] => 1
)
[time] => 1.39
)
)
Local install without quotations around the int (working)
Array (
[0] => Array (
[query] => select * from `users` where `users`.`id` = ? limit 1
[bindings] => Array (
[0] => 1
)
[time] => 0.84
)
[1] => Array (
[query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
[bindings] => Array (
[0] => 1
)
[time] => 1.15
)
)
Production installation without quotations around int (not working)
Array (
[0] => Array (
[query] => select * from `users` where `users`.`id` = ? limit 1
[bindings] => Array (
[0] => 1
)
[time] => 2.3
)
[1] => Array (
[query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
[bindings] => Array (
[0] => 1
)
[time] => 0.67
)
)
Production installation with quotations around int (working)
Array (
[0] => Array (
[query] => select * from `users` where `users`.`id` = ? limit 1
[bindings] => Array (
[0] => 1
)
[time] => 0.88
)
[1] => Array (
[query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
[bindings] => Array (
[0] => 1
)
[time] => 0.81
)
)
Solution:
It turns out I didn't have mysqlnd as the active driver on my server. Activating it solved the issue.