Under the Laravel 7 (php7) system, if I query any id of my table, there is no result, but if I enter the id value as a string, then there is a result.
In the table, the id column type is int(11). There is also the principle of primary key and index.
What could be the problem?
Not working:
DB::table('table_name')->where('id', 1)->first();
Working:
DB::table('table_name')->where('id, '1')->first();
This is because the query builder is taking integer 1 as a boolean true value instead of a integer value, but when you write 1 as a string it simple matches the value in the column and not the datatype.