Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fabio571's avatar

Query builder problem

Hi, i have a problem with the query builder that's quite odd. I have this two queries:

$tmp2 = Temp2::where('parent',54125)->get();
$tmp3 = Temp2::where('parent','54125-G')->get();

I get the same collection as result. I really cannot understand why. If i cast 54125 as string the query works properly. And i get an empty collection. The field 'parent' is VARCHAR(20). In the table there are only 4 records with parent 54125-G. Any hint? Thank you

0 likes
1 reply
rebirthtobi's avatar

Since you say you are using VARCHAR(20), this can store both integer and string but its treated as a string and therefore use them as a string in your where clause

Please or to participate in this conversation.