It depends on your column type and the mysql server configuration.
You have to know all bindings are escaped as strings with pdo. You must have a strang pdo or mysql configuration on your local machine
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
am I right that MySQL usually returns int as strings ? On my forge instance it is exactly the opposite and my queries are not working anymore.
If I do:
$variable->where('foo', '1')->first();
on my local machine it works fine. But on my forge server it fails ! If I change it like so:
$variable->where('foo', 1)->first();
it works again on my production server, but not on my local machine.
So why is the return different on forge? Anyone ever had same issues ?
Is $variable a collection or a query builder ?
I guess it is a collection. By default the where method use type comparison too. If you want to loosely compare the value add false as third parameter $variable->where('foo', '1', false)->first();. Or use $variable->whereLoose('foo', '1')->first();.
Please or to participate in this conversation.