Support the ongoing development of Laravel.io →
Database Eloquent

I have a tinyint column named 'status' in the database which is created by boolean function of migration class.

My problem is;

when i use where('status', '1') it works on my server but does not work in my localhost

when i use where('status', 1) it works in my localhost but does not work on my server

ps: i tried where('status', true), where('status', '=', 1) and where('status', '=', true) the results are always the same.

Last updated 3 years ago.
0

did you create the tables manually or using migrations? if migrations, did you use boolean or tinyint(1)?

Also check where you are setting this value and how?

0

As I mentioned above, it is generated with migrations and I used boolean method (as I mentioned above).

0

What about the difference in DBs between local and server

0

What about the difference in DBs between local and server

0

Localhost: mysql Ver 15.1 Distrib 10.0.20-MariaDB, for Linux (x86_64) using readline 5.1

Server: mysql Ver 15.1 Distrib 10.0.20-MariaDB, for Linux (x86_64) using readline 5.1

The problem is that it does not query at all.

0

localhost server

Guys i realized something. Types of the every attributes are strings, which is not normal I suppose.

0

check your db schema. also consider using eloquent's attribute casting. so the status is always stored as an int rather than a string.

but still where status = 1 is the same as status = "1" if you are storing the status as string.

0

Sign in to participate in this thread!

PHPverse

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.

© 2025 Laravel.io - All rights reserved.